Re: Need to stop form from going to first record
- From: "Stuart McCall" <smccall@xxxxxxxxxxxxxxx>
- Date: Fri, 4 Jan 2008 20:39:39 -0000
"Tofudisan" <TofuTheGreat@xxxxxxxxx> wrote in message
news:146bdd89-06cc-49d5-8014-7d25404b5e4f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The form is based off a query of the table. I've coded all the adds,
updates, and deletes to use either SQL or stored procedures so that I
can validate everything before I let it get into the back-end
database.
However I can quickly flip it over to being based off the table
directly if needed.
If you're going to manage all updates yourself, you really ought to be using
an unbound form. The reason I say that is that a bound Access form does
automatic updates for you IF you let it. There are two events you should
look at: BeforeInsert and BeforeUpdate. The first one fires just before a
new record is automatically inserted into the dataset. The second fires just
before a record that has been edited is inserted. Both events allow you to
cancel the auto-update by setting a variable called Cancel to True. Access
passes this variable to your procedure in the parameter list. So something
like:
If <ValidationFailedSomehow> Then
MsgBox "Cannot update the database because ... blah blah"
Cancel = True
End If
When this code executes, the user will be unable to 'move away' from the
current record until the problem is fixed (or they undo their changes).
Using a form in that manner is natural for Access and doesn't require any
further SQL or stored procedures in order to update your data.
Of course if you are using stored procedures for performance or security
reasons, then you may need to stick with that. If you do, make your form
unbound (clear its RecordSource property). If you leave it bound, your
record is being saved twice - once by your code and once by the form.
.
- References:
- Re: Need to stop form from going to first record
- From: Tofudisan
- Re: Need to stop form from going to first record
- From: Stuart McCall
- Re: Need to stop form from going to first record
- From: Tofudisan
- Re: Need to stop form from going to first record
- Prev by Date: Re: Filtering Subform
- Next by Date: Re: Filtering Subform
- Previous by thread: Re: Need to stop form from going to first record
- Next by thread: Re: Confirm data change on close
- Index(es):
Relevant Pages
|