2
votes

I have a button on a form whose purpose is to add a new record to the underlying table.

The OnClick Event code for the button looks like

  me.dirty = false

  if me.NewRecord then
     msgBox("new record")
  else
     msgBox("not new record")
  end if

  doCmd.goToRecord record := acNewRecord

The message box is needed to make sure that I am not already operating on a new record.

When I click the button, I get a Runtime error 2105 "You can't go to the specified record"

Does someone know why this is?

Rene

3
what is the query/datasource behind the form? Is it as simple as a table to be able to add new record? - shahkalpesh

3 Answers

2
votes

Never Mind, I found the problem

I should have used

doCmd.goToRecord record := acNewRec

instead of

doCmd.goToRecord record := acNewRecord

Yet, why access won't tell me that it doesn't know about acNewRecord....

Edit: Of course David was right: I haven't set OPTION EXPLICIT.

0
votes

I was able to resolve the 2105 issue by selecting a unique record identifier for the underlying linked table that was the record source for the MS Access form.

-1
votes

double click on the up left point on the small black squere in the form to have the main properties of the form, then go to the data tap and click the Record source button, you will see that the form is linked to another table which is prevent the form to add new records, remove that table, and I hope that will solve your problem. Salam...