Adding and detecting new records

ClaraBarton

Registered User.
Local time
Today, 09:33
Joined
Oct 14, 2019
Messages
661
I'm calling a detail form from a list form. Usually the detail form is called with a where condition and goes to that record.
However, I also have a New button that calls the detail form in datamode:=acformadd.
To add a new record there are a couple routines I need to run first, so on load :
Code:
If me.newrecord then
     Call a routine
End If
The me.newrecord always returns 0 and skips to End.
How is this possible if I've called it acformadd? There is no data. It is new.
 
you can also Check if your PK is Null for New record.
 
I just tested that, and I got the expected results. Maybe you have other code that's saving the new record before the check, so it's not a new record anymore?
 
Well! Checking the PK works great! Why doesn't the other work? Thank you very much.
DBguy... since it's on the load event how would that be possible?
 
Load events only fire once when the form is first loaded (and just after the Form Open event. Changing records (including creating a new record) uses the Current event, which might be where you need to do your testing. See this article to learn about the detailed order of events.

 
If you walk your code you will see that the Current event is called after the Open and Load events. Plus a few others.
As Doc states, that would be where I would test.

What would happen, if I decided to add more than one record. Do I have to go back to the previous form and start all over again? :(
 

Users who are viewing this thread

Back
Top Bottom