current record vs record count

  • Thread starter Thread starter Laurel
  • Start date Start date
L

Laurel

Sometimes my my form gets into a state where recordcount > 0 but
currentrecord = 0. That being the case, the code that was to be executed if
recordcount > 0 fails because there is no current record. I can't figure
out the pattern for this (this happens much less frequently since I began
executing DoCmd.RunCommand acCmdSaveRecord before doing the test, but it
still happens sometimes). The form appears to have a current record. You
can see the record that the user just entered data into, and it has an arrow
next to it.

Is there anything I can do to force the currentrecord value to be > 0 if
recordcount is > 0?

Does anyone know what conditions might cause this to happen (even when the
acCmdSaveRecord is executed?)
 
I think I found the thing that causes this to happen. One of my functions
had the Set Recordset before the save command instead of after. Moving Set
lrstMe = Me.Recordset to the bottom of these statements seems to have fixed
the problem.

DoCmd.RunCommand acCmdSaveRecord 'Make sure newly added row is recognized
is_Debug = Me!Student_ID
DoEvents
is_Debug = Me!Student_ID
Set lrstMe = Me.Recordset
 
Back
Top