Mike Krailo
Well-known member
- Local time
- Today, 02:31
- Joined
- Mar 28, 2020
- Messages
- 1,043
This is probably an easy one for you but it is not making a lot of sense to me why this error is happening. The code on the ADD button is on subform of a main form and is obviously used to add records. The very first time the main form loads, I can press that ADD button on the subform and there is no error. If that new record is now deleted, and the ADD button is pressed again, that's when the "No Current Record" error occurs. Using the On Error Resume Next did not help at all either. So obviously, there are no records to start with. Going to a new record where there is none currently doesn't seem like it should generate that error. What's going on here?
Having stepped through the code, this error is generated prior to the On Click event firing (second time through after main form loads). No idea why this is happening!
Having stepped through the code, this error is generated prior to the On Click event firing (second time through after main form loads). No idea why this is happening!
Code:
Private Sub AddBtn_Click()
If Nz(Me.Parent.JobDateClosed) <> 0 Then
' There is a closed date, so do not allow additions
MsgBox "This Job is closed for adding records!"
Exit Sub
Else
Me.AllowAdditions = True
' On Error Resume Next
' DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.GoToRecord , , acNewRec
Me!TaxTypeID = 1
Me.AllowAdditions = False
End If
End Sub