Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required error in access db sub procedure 1

Status
Not open for further replies.

quesnelljc

Technical User
Nov 4, 2008
6
0
0
GB
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.
 
That should be:

If IsNull(Forms![Data]![SR number]) Then


There are specific fora for Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top