Form question?

G

G Lam

Hi, I have a form to add data on the fly. When user enters the part# in a
field of order input form, the afterupdate event will check if the part#
exists in the part# table. If it is not, a AddPart form will pop up and asks
the user to input the new part data.
I want the part# entered in the order input form carry to the Addpart form,
but unable to do that.
In the Order Input form!partnbr afterupdate event, I put a line of code like
this:
if dlookup return null then:
DoCmd.OpenForm "FrmAddPart", acNormal, , "PartNbr = """ & L & """",
acFormAdd, acDialog
L is a string variable that equals the part# entered by the user in the
order input form.
The FrmAddPart's data source is a query "qryAddPart" from the tblParts,
which has on two fields - PartNbr, Description.
I also tried
DoCmd.OpenForm "FrmAddPart", acNormal, , "PartNbr = """ & L & """", ,
acDialog
DoCmd.OpenForm "FrmAddPart", acNormal, , "PartNbr = " & L , , acDialog
DoCmd.OpenForm "FrmAddPart", acNormal, , "PartNbr = " & L , acFormAdd,
acDialog
or add another line:
frmAddPart!PartNbr = L
or
forms!frmAddPart!PartNbr = l
but none of them worked.
I checked in the immediate window, the L did has the part# value.
How Can I get it right?
Thank you.
Gary
 
G

Glenn

You could pass the part# (L) as the openargs value
(DoCmd.OpenForm "FrmAddPart", acNormal, , , , , L)
and then in the OnOpen event of FrmAddPart type:
Me.PartNbr = Me.Openargs

Glenn.
 

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