"Object Required" error

PaulA

Registered User.
Local time
Today, 09:50
Joined
Jul 17, 2001
Messages
416
Greetings--

I have a command button that executes code to determine that all appropriate fields have values (not null) before clearing the fields to add a new record.

I have used this set up many times (including in this particular database) but in one instance I am getting an "Object Required" message when clicking on the command button.

Any ideas why this would be happening? I use A2K.

Thanks.
 
Post you code please so we can see what may cause the problem.
 
Here is the code:

Private Sub cmdNewRecord_Click()
On Error GoTo Err_cmdNewRecord_Click

If IsNull(Me.Date) = True And IsNull(Me.Resident_Staff_involved) = True And IsNull(Me.IncidentCategory) = True And IsNull(Me.IncidentDescription) = True And IsNull(Me.Outcome) = True And IsNull(Me.IncidentStatus) = True Then
DocmdNewRecord.GoToRecord , , acNewRec
Me.StartDate = Null
Me.EndDate = Null
Me.Refresh
Me.Date.SetFocus
Else
If IsNull(Me.Date) = False And IsNull(Me.Resident_Staff_involved) = False And IsNull(Me.IncidentCategory) = False And IsNull(Me.IncidentDescription) = False And IsNull(Me.Outcome) = False And IsNull(Me.IncidentStatus) = False Then
DocmdNewRecord.GoToRecord , , acNewRec
Me.StartDate = Null
Me.EndDate = Null
Me.Refresh
Me.Date.SetFocus
Else
MsgBox "Current screen has incomplete record. Please complete record or press 'Delete Record' button to clear record."


Exit_cmdNewRecord_Click:
Exit Sub

Err_cmdNewRecord_Click:
MsgBox Err.Description
Resume Exit_cmdNewRecord_Click
End If
End If
End Sub
 
I guess it has to do with SetFocus somewhere in your code. Why don't you rem the lines and see if it helps. Or rem the On Error GoTo Err_cmdNewRecord_Click line, and try to click the button. When you are prompted for the error message, just click debug button. There you will see what line causes the problem.
 
Thanks for the tip--

The reason I don't use the "required" property in certain base tables is that I have my forms set up to refresh after the update of certain fields. I have found that refreshing will trigger a "null value" error message is generated even if I haven't gotten to that field yet!

My forms are very automated.

Any suggestions?
 

Users who are viewing this thread

Back
Top Bottom