Solved Understanding Events code not responding (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:45
Joined
Feb 19, 2002
Messages
36,284
Setting DataEntry to true prevents the form from showing old records. That means you need a button on the main form to toggle the DataEntry property of the subform. This is probably the easiest way to achieve your objective of always going to an empty record.

Personally, I don't like manipulating subforms this way. When a user opens this form, how frequently is it to add a new record to the subvorm vs view/change the data in the main form or view/change the data in the subform. Seems to me that at least half the time you want to log out so that tips the balance to mostly you want to see existing records and less than half the time, you want to add a new record so I would NOT automatically go to a new record.

After reading your code more closely, it looks like you want to manipulate which controls are enabled. The easiest way to do this is with the Me.NewRecord property. Everything can be enabled for new records. The reason for not disabling the logout is because if someone logs in and out at the same time, locking the logout just makes that annoying because you have to save the record, leave it, and then go back. For existing records, the Login can be disabled and if the logout is already populated, you can set the AllowUpdates property to No rather than locking individual fields.
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:45
Joined
Feb 28, 2001
Messages
22,778
I read the link several times and couldn’t get the code to add new record. I ended up setting the data entry property to yes and that worked. Will this be ok and to standards?

OK, here is the syntax that I think might help. Maybe. Again, assume that the sub-form control is named MySFC, which is NOT repeat NOT the name of the subform itself. It is the sub-form control's name.

Code:
DoCmd.GoToRecord acDataForm, Me.MySFC.Form.Name, acNewRec

In this case, you can omit the 4th argument, which will default it to 0 offset.
 

Users who are viewing this thread

Top Bottom