Save Record, Append New

B

Bonnie

Hi,

Can anyone tell me what I am doing wrong. Here's the code on a command
button:

If Not IsNull(Me.Doors1.Column(0)) Then
Me.OrderItemNo = Me.Doors1.Column(0)
Me.ItemQty = Me.Qty1
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord acDataForm, "Forms!OrdersGarage", acNewRec
End If

I get an error: "Forms!OrdersGarage" isn't open. I know it's open, it's
the form the command button is on.

Thanks in advance.
 
M

Minton M

Bonnie,

You don't need to specify the object name if you're working on the
same form that the code is running from: just use....

DoCmd.GoToRecord , , acNewRec

.... I can't tell if the syntax below is correct without seeing the db,
but I suspect there something wrong in the way you're referring to the
form. In any case, this should work.

-- James
 
B

Bonnie

Thanks Minton. I'll use it.

Minton M said:
Bonnie,

You don't need to specify the object name if you're working on the
same form that the code is running from: just use....

DoCmd.GoToRecord , , acNewRec

.... I can't tell if the syntax below is correct without seeing the db,
but I suspect there something wrong in the way you're referring to the
form. In any case, this should work.

-- James
 
T

Tony Toews [MVP]

Bonnie said:
If Not IsNull(Me.Doors1.Column(0)) Then
Me.OrderItemNo = Me.Doors1.Column(0)
Me.ItemQty = Me.Qty1
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

The new syntax is
docmd.runcommand accmdsaverecord.
Some of the wizards use rather old syntax.
DoCmd.GoToRecord acDataForm, "Forms!OrdersGarage", acNewRec

The preferred syntax here would be
DoCmd.GoToRecord , , acNewRec

Tony


--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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