Pass a Value to OpenArgs

  • Thread starter Thread starter Lynn
  • Start date Start date
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"
 
-----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-----
 
Back
Top