I'm having a problem with an entry form on one of my applications. It
would appear that the save action is sometimes not working, and is
generating no error when it fails. I'm hoping one of you may have some
insight into what is causing the problem.
I'll describe only the general outline since the actual code is several
pages long.
1. Entry form opened in Data Entry mode
2. Global variable SaveRec set to False on form load.
3. User displayed 2 bound controls (ID [AutoNumber], and Title [Text])
and an unbound control (Description [memo])
4. User fills in controls and AutoNumber field is generated
5. User clicks Save button
6. Validation run to insure all fields filled in and that AutoNumber
field contains a value
7. Value in AutoNumber field saved to GlobalVariable IDHold
8. Global variable SaveRec set to True
9. DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
10. Open recordset on table where the above record was created using
criteria stored in IDHold
11. If recordcount = 0, display error and exit Save Button module Else
continue
12. *Many other steps beyond this, but they appear to work just fine.
*The Form's Before Update event occurs immediatly after the save record
command.
Form Before Update
If SaveRec = False
Me.undo
End if
End sub
My problem is on step 11. 95% of the time the record is saved
correctly. However, sometimes the record isn't found because it wasn't
saved. No error is being generated so I have no idea why the save did
not go through. Some users have this problem occur more than others and
the ones that have it happen most often are users located offsite
(WAN). If this problem does occur, the user has to click the Finish
button once or twice more before the record is finally out there and
available for the recordset to find.
My question is this: does the save record command wait to complete
before advancing to the next line of code, or will it only initiate the
save action before moving on? By what I can tell, it would appear to be
the latter. If it only initiates the save, is there anyway to delay the
code until the save action is complete?
Thanks in advance for any advice you might have!
P.S. I could just do the whole thing with a recordset and use the
..update method, but the users want to be given the record number while
they are entering it rather than after.