I'm calling a public function from command button which goes to a new record on a single form:
Public Function NewRecord(ctl As Control)
DoCmd.GoToRecord , , acNewRec
Problem is if a record is being edited (dirty) and I click the Add Record button before the record gets saved, Access tells me I can't go to the specified record (run-time error 2105). Not sure why this is so. I have an event procedure in the BeforeUpdate of
the form which confirms data changes:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then
Dim msg, style, TITLE, Response
msg = "Record(s) have been added or changed." & vbCrLf & "Do you want to save the changes?"
style = vbYesNo + vbQuestion
TITLE = "Data Change Confirmation"
Response = MsgBox(msg, style, TITLE)
If Response = vbYes Then
The BeforeUpdate triggers when I click the New Record Button but after that the run-time error 2105 pops up highlighting 'DoCmd.GoToRecord , , acNewRec'.
Why am I unable to got to a new record in this situation?? The Form's Allow Additions property is set to Yes.
This thread is locked. You can follow the question or vote as helpful, but you cannot reply to this thread.