Pass a Value to OpenArgs

L

Lynn

I have a main form with a subform. From the subform you
can check a box to open a popup form. The problem is I
can't get the subform to pass the primary key to the
OpenArgs.

Here is the code:

Private Sub ckAltShippingAddr_Click()

Dim stDocName As String
stDocName = "frmAltShippingAddr"

If Me.ckAltShippingAddr = True Then
'DoCmd.OpenForm stDocName, , , , , , "[ReqItemID]=" & Me!
[ReqItemID]
DoCmd.OpenForm stDocName, , , , , , Forms!frmReq.Form!
sbfReqItems.Form.txtReqItemID

End If

End Sub

If I hard code a value it works fine, e.g.,
DoCmd.OpenForm stDocName, , , , , , "2"
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You're first OpenForm command line is incorrect because you forgot the
"txt" before the control's name. Using Me! means refer to the control
name after the exclamation point on the current form. You have set it
up to refer to a control that may/may not be on the form (since in the
2nd command you refer to the control as "txtRegItemID." Try this:

DoCmd.OpenForm stDocName, OpenArgs:=Me!txtRegItemID

BUT, you may be trying to FILTER the opening form. In that case use
this example:

DoCmd.OpenForm stDocName, WhereCondition:="ItemID=" &
Me!txtRegItemID

This supposes that the "stDocName"'s RecordSource has a column named
"ItemID." Substitute the correct name.

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQCGS8oechKqOuFEgEQI8zQCcCVtvmNZnf9nA6qjPnlnOoY03sBYAoLSW
4OZTCusUTFDjBh38CJP6DOdW
=eAPU
-----END PGP SIGNATURE-----
 

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