Runtime error '2105' "You can't go to the specified record"
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"开发者_JAVA技巧)
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
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
.
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.
i also have faced this issue and in my case this belowed solution worked well try this ,
if form doesn't allow you to add new record then make sure that before the form opensup all the other forms that also used tha same table as datasource are needs to be close first.
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...
精彩评论