Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detect new record 3

Status
Not open for further replies.

jimb0ne

Programmer
Oct 6, 2003
291
0
0
CA
Hi All,
I'm having some trouble, basically I want to be able to figure out from code if someone is adding a new record or if they are working on records which already exist. So basically if someone uses the record selectors to go to the last record, then advance one to add a new record, I want to be able to detect that from code. I don't know if there is a property which would indicate this, but I sure hope so. I've checked absoluteposition, BOF, EOF but none seem to reflect the fact that a new record is being added. Any help would be much appreciated.

Thanks,
James
 
Have you looked at the "EditMode" property? This property has 3 possible results:

dbEditNone = No record currently being edited or added
dbEditInProgress = Current Record currently being edited
dbEditAdd = Adding a new property

Note, the 3 variables above are constants, so they equal

dbEditNone = 0
dbEditInProgress = 1
dbEditAdd = 2

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
rdodge,
Thanks for the help, but I've checked the editmode property and its returning 0 regardless of where I am making changes to the DB. Any other ideas?

Thanks again,
James
 
You could set the form property AllowAdditions to False and put a button on your form to Add records. That button could re-open the form in the Add new record mode or go to a new record after changing the AllowAdditions property to true.
 
Me personally, I don't work with bound forms due to the high level of both, user friendliness of the forms and stringent data validation checks at the appropriate times, so I been using DAO coding on unbound forms/controls instead. However, with that, it also means the code must control on when to put a record in edit mode, when to put the recordset in add new record mode, and when not to go into either mode, which then at other points of time, the code can check this EditMode property to determine which course of action it will take.

With bound forms, first check the "Dirty" property on the form to see if there's any editing taking place, and if it is true, then check the "NewRecord" property to determine if the current record is a new record or not.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
rdodge,
Thanks for the help, newrecord property is exactly what I was looking for, I guess I was just looking for it in the wrong place!

Thanks again,
James
 
Good call, Ronald - star for you! I needed to NOT run the procedure if the record was a new record, because I referenced the AutoNumber - and at that point, it doesn't exist.

Here's the code I ended up using:

If Me.NewRecord Then
GoTo Update_Vendor_Combination_End_Click
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top