views:

1140

answers:

1

Hello

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

+1  A: 

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....

René Nyffenegger
Sounds like your code module doesn't have OPTION EXPLICIT set in the declarations section. If it does and you compile, acNewRecord will be identified as an undeclared variable.
David-W-Fenton