Error time-stamping a record -- sometimes. 
Author Message
 Error time-stamping a record -- sometimes.

I'm having some problems understanding what is happening in the process of a
form changing record while needing to set fields in the originating record
(through the beforeUpdate event procedure. I have a form that date/time
stamps records if they have been modified. It uses the form_beforeUpdate
event procedure to accomplish this by simply setting a field (DLM) to now().
(It also sets a User field.) Both of these fields happen to be on the form,
but my understanding is than they don't need to be, as long as they are in
the recordset underlying the form. I do not use  .Edit .. .Update methods
before and after setting the fields.

There are two common ways for a user to move to another record (and thereby
triggering the form_BeforeUpdate event): One is by clicking on a record
navigation button that executes a docmd.findnext to move ahead/back one
record. This seems to work just fine. The problem occurs when the user uses
a combo box (with the same table as the recordsource underlying the table as
the combo contents). The user selects an item, and the software starts to
take him to the selected record. This takes a somewhat different path, but
both this method and the former one come to the beforeUpdate procedure. In
the latter case, however, the program chokes ( attemped changes with out
Edit or Update methods  ). The only thing I've been able to focus in on is
the status of the form at different steps in the process -- remembering that
in both cases, the current record is about to be left, a new record is about
to be entered, but the fields needing updating are in the old record. I am
uncertain exactly what happens during the triggering of events in this case
and which record is actually 'current' at various points in the process.
Doing step-by-step debug indicates that we are already on the new record,
even though we haven't completed the beforeUpdate procdure has completed.

Is there some special understanding needed regarding record movement and
event triggering that needs to be understood in order to sort this out:?

dds



Wed, 20 Jul 2005 05:41:24 GMT  
 Error time-stamping a record -- sometimes.
Assuming your navigation combo is unbound, try adding this to the top of its
event:
    If Me.Dirty Then
        Me.Dirty = False
    End If
This forces the save before the move is attempted, and returns an error
message if the save can't take place. (The error says setting the Dirty
property failed.) This will prevent a range of problems later.

If the combo is bound, it's a different story. Personally I don't think a
single control should be used for two purposes (to store a value, and also
to move record).

--
Allen Browne - Microsoft MVP (Most Valuable Professional)
Allen Browne's Database And Training - Perth, Western Australia.
Tips for MS Access users - http://allenbrowne.com/tips.html
Reply to the newsgroup. (Email address has spurious "_SpamTrap")


Quote:
> I'm having some problems understanding what is happening in the process of
a
> form changing record while needing to set fields in the originating record
> (through the beforeUpdate event procedure. I have a form that date/time
> stamps records if they have been modified. It uses the form_beforeUpdate
> event procedure to accomplish this by simply setting a field (DLM) to
now().
> (It also sets a User field.) Both of these fields happen to be on the
form,
> but my understanding is than they don't need to be, as long as they are in
> the recordset underlying the form. I do not use  .Edit .. .Update methods
> before and after setting the fields.

> There are two common ways for a user to move to another record (and
thereby
> triggering the form_BeforeUpdate event): One is by clicking on a record
> navigation button that executes a docmd.findnext to move ahead/back one
> record. This seems to work just fine. The problem occurs when the user
uses
> a combo box (with the same table as the recordsource underlying the table
as
> the combo contents). The user selects an item, and the software starts to
> take him to the selected record. This takes a somewhat different path, but
> both this method and the former one come to the beforeUpdate procedure. In
> the latter case, however, the program chokes ( attemped changes with out
> Edit or Update methods  ). The only thing I've been able to focus in on is
> the status of the form at different steps in the process -- remembering
that
> in both cases, the current record is about to be left, a new record is
about
> to be entered, but the fields needing updating are in the old record. I am
> uncertain exactly what happens during the triggering of events in this
case
> and which record is actually 'current' at various points in the process.
> Doing step-by-step debug indicates that we are already on the new record,
> even though we haven't completed the beforeUpdate procdure has completed.

> Is there some special understanding needed regarding record movement and
> event triggering that needs to be understood in order to sort this out:?

> dds



Wed, 20 Jul 2005 11:33:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Time stamping the time a record was added to a table

2. Time stamping a record??

3. A hidden time stamp for each new record?

4. VB 5.0 Copy Error Adds 2 Seconds to time Stamp

5. sometimes he does it sometimes he doesn't

6. ADO recordset : Resync sometimes works and sometimes failed

7. Sometimes works sometimes does not

8. Seek sometimes doesn't match record

9. Crystal DON'T show the last record (sometimes), reprinting DO

10. Recording Stamping

11. Date and Time Stamp for a Field Being Modified

12. Return File Date Time stamp

 

 
Powered by phpBB® Forum Software