on load event

  • Thread starter Thread starter myxmaster
  • Start date Start date
M

myxmaster

Hello, I have the following code in the load event of a form named new
player:

Private Sub Form_Load()
DoCmd.GoToRecord acForm, Me.Name, acNewRecord
End Sub

When ever I load the form I get an error message

runtime error 215
you cant go to the specific record.

I simply wish to open the form with empty fields. Any help sis most
appreciated.
Tia
 
There are several things that could go wrong here, such as
a) you are already at a new record,
b) the form doesn't allow new records,
c) the form in a mode that doesn't respond to that code,
d) the form's source data is read-only (joins in query, inconsistent
dynaset, ...),
e) the form is unbound,
f) there is code in another event that prevents this from working,
g) there's a problem with user permissions,
h) other stuff neither you nor I thought of.

The following handles the first 3 of those cases anyway:
If Me.AllowAdditions And Not Me.NewRecord Then
RunCommand acCmdRecordsGotoNew
End If

Include error handling to recover from the other cases.
 
Back
Top