Adding new records to a table in VB code

J

jim

I have a rather complicated form that loads several arrays with fields that
I need to add to a table. When I go to another form that 'should' add the
new records (using a for/next loop) it stops and gives me this message:

Run-time error '2499': You can't use the GoToRecord action or method of an
object in Design view.

I have this line of code right after the 'For' clause:

DoCmd.GoToRecord , , acNewRec

and just before the 'Next' statement I have this line:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, acMenuVer70

I have used that in an earlier version and it created new records and saved
each one. If I take both statements out it creates only the last record
(out of 366.)

Any advice would be appreciated!
 
P

pietlinden

I have a rather complicated form that loads several arrays with fields that
I need to add to a table. When I go to another form that 'should' add the
new records (using a for/next loop) it stops and gives me this message:

Run-time error '2499': You can't use the GoToRecord action or method of an
object in Design view.

I have this line of code right after the 'For' clause:

DoCmd.GoToRecord , , acNewRec

and just before the 'Next' statement I have this line:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, acMenuVer70

I have used that in an earlier version and it created new records and saved
each one. If I take both statements out it creates only the last record
(out of 366.)

Any advice would be appreciated!

Why not just use a recordset? Use AddNew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top