"You can't go to the specified record" error

Pis7ftw

Registered User.
Local time
Today, 13:12
Joined
Aug 5, 2012
Messages
37
Having trouble tracking down an error.

I have a form, when a textbox or combobox IsNull or "" then label.forecolor = labelcolor (which is declared variable) and setfocus to blank text/combobox when the "Add Record" button is pushed.

Code:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    If Pain_Date1 = "" Or IsNull(Pain_Date) Then
        Me.Pain_Date1.SetFocus
        MsgBox "All fields in this audit are required."
        DoCmd.CancelEvent
        Me.Pain_Date_Label.ForeColor = vbRed
        Exit Sub
    End If

Running the form, leave the text/combo blank and press button it will give me msgbox then after msgbox is cleared then Microsoft Access gives me a msgbox saying "You can't go to the specified record".

What up?

And thanks!
 
As soon as I posted this a thought occurs. The "Add Record" is a standard macro Add New Record. I'm wondering if I put in another button with the above code and called it verify and then kept the Add Record as the Add New Record macro, it will eliminate this issue.
 
Do not use:
DoCmd.CancelEvent

Use
Cancel = True
 
K I'll give that a shot before I start adding new buttons. Thanks!
 
Replaced the DoCmd.CancelEvent with Cancel = True. No change in the error.
 
Yup! Adding the new button for verification worked perfectly!

Sorry to clutter up the forum with questions I answered myself!
 
The "Submit Audit" was set for Add New Record macro.

I added a new one called Verify Audit to be pushed prior to submit (will make submit disabled until verify occurs). The verify button contains the code that I previously embedded.
 

Users who are viewing this thread

Back
Top Bottom