I have:
-Form "frmInvoice" with subform "Allocation" based on table "tblInvoice" and "tblAllocation". "invID" is auto number in tblInvoice and joins main form "frmInvoice" and subform "Allocation".
-Label report "Labels qryLabels," based on a query qryLabels. qryLabels is based on tblInvoice and tblAllocation. label report "Labels qryLabels" has "invID" field.
In form "frmInvoice," there is a command button "Command260", and when a user clicks this button, only label report that has same invID as the current form shows up.
I tried the following code and didnt work.
Expand|Select|Wrap|Line Numbers
- On Error GoTo Err_Command260_Click
- Dim stDocName As String
- Dim strgetinvID As String
- strgetinvID = Me.invID
- ' (I also tried "=Me.invID.Value)
- stDocName = "Labels qryLabels"
- DoCmd.OpenReport stDocName, acViewPreview, , invID = strgetinvID
- Exit_Command260_Click:
- Exit Sub
- Err_Command260_Click:
- MsgBox Err.Description
- Resume Exit_Command260_Click
- End Sub