quesnelljc
Technical User
I am having some difficulty with the above error "object required" being returned when running a sub procedure in an access database. Quite simply I would like the on click command to return a message box if a particular condition is met. Here is my code:
Private Sub Command130_Click()
Dim intresponse As Integer
On Error GoTo Err_Command130_Click
If Forms![Data]![SR number] Is Null Then
MsgBox "A valid SR number has not been assigned to this record." _
& Chr(10) & "The SR number should not be 0.", vbOKOnly
Exit Sub
End If
If Forms!Data![DTPicker4] < Date + 1 Then
intresponse = MsgBox("The 'Next Action Date' has not been set for a future date." & Chr(10) & _
"Do you want to set a follow up date?", vbYesNo, "Next Action Date")
If intresponse = vbYes Then
DoCmd.GoToControl "[DTPicker4]"
Else
DoCmd.Close acForm, "Data"
End If
Else
DoCmd.Close acForm, "Data"
End If
Exit_Command130_Click:
Exit Sub
Err_Command130_Click:
MsgBox Err.Description
Resume Exit_Command130_Click
End Sub
The problem is related to my first if statement. If I remove or comment this out it works as expected. I can't understand why the second if statement works fine but the first returns the "object required" error.
Any help would be greatly appreciated.
Private Sub Command130_Click()
Dim intresponse As Integer
On Error GoTo Err_Command130_Click
If Forms![Data]![SR number] Is Null Then
MsgBox "A valid SR number has not been assigned to this record." _
& Chr(10) & "The SR number should not be 0.", vbOKOnly
Exit Sub
End If
If Forms!Data![DTPicker4] < Date + 1 Then
intresponse = MsgBox("The 'Next Action Date' has not been set for a future date." & Chr(10) & _
"Do you want to set a follow up date?", vbYesNo, "Next Action Date")
If intresponse = vbYes Then
DoCmd.GoToControl "[DTPicker4]"
Else
DoCmd.Close acForm, "Data"
End If
Else
DoCmd.Close acForm, "Data"
End If
Exit_Command130_Click:
Exit Sub
Err_Command130_Click:
MsgBox Err.Description
Resume Exit_Command130_Click
End Sub
The problem is related to my first if statement. If I remove or comment this out it works as expected. I can't understand why the second if statement works fine but the first returns the "object required" error.
Any help would be greatly appreciated.