By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

New Record Not Working

100+
P: 158
I have two forms and when form 2 is loaded it is supposed to create a new record. This was working only when there were other records in the table. I have cleared out the records in the table that form 2 is built off of and now when i launch it, form 2 gives me this error

Run-time error '2105': You can't go tot he specified record.

heres my code that it brings up when I click Debug

DoCmd.GoToRecord , , acNewRec

Is there a way to add a new record without using the GoToRecord command in VBA? I think that this would fix my problem.

Thanks!
May 21 '08 #1
Share this Question
Share on Google+
2 Replies


nico5038
Expert 2.5K+
P: 3,072
I have two forms and when form 2 is loaded it is supposed to create a new record. This was working only when there were other records in the table. I have cleared out the records in the table that form 2 is built off of and now when i launch it, form 2 gives me this error

Run-time error '2105': You can't go tot he specified record.

heres my code that it brings up when I click Debug

DoCmd.GoToRecord , , acNewRec

Is there a way to add a new record without using the GoToRecord command in VBA? I think that this would fix my problem.

Thanks!
Are you sure form 2 has the "Allow Additions" property set to "Yes" ?
Another option is to create a form 2 with the "Data Entry" property set to "Yes" to make sure a new record is forced each time.

Nic;o)
May 21 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
I'm not sure exactly what's going on with your form. How exactly did you "clear out the records in the table?" You didn't, by chance, simply delete the table, did you? That might cause the error you cited, since the form would no longer have a valid Record Source.

I assume that the line

DoCmd.GoToRecord , , acNewRec

is in the form's OnLoad event, which is where it belongs. Placement elsewhere might cause the error. If the underlying table exists but is empty, this code shouldn't cause an error.

If your intent for this form is to only allow the adition of records, and not allow the viewing of existing records then
  • Delete the line DoCmd.GoToRecord , , acNewRec
  • In Design View for the form goto Properties - Data and set the Data Entry Property to Yes
This will only allow new recordsto be added.

Linq ;0)>
May 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.