open report by form field vale (1 Viewer)

naobao

Registered User.
Local time
Today, 11:11
Joined
Feb 13, 2014
Messages
76
Hi,

I want to open report by a from button,
the report name is base on a subform field value,
How can I do this?

Thanks!
 

Ranman256

Well-known member
Local time
Today, 14:11
Joined
Apr 9, 2015
Messages
4,337
in the query, set it to look at the subform value.
Use the FULL path....use the BUILDER to get it right.

select * from table where [field] = forms!myForm!subForm.form.txtBox
 

naobao

Registered User.
Local time
Today, 11:11
Joined
Feb 13, 2014
Messages
76
in the query, set it to look at the subform value.
Use the FULL path....use the BUILDER to get it right.

select * from table where [field] = forms!myForm!subForm.form.txtBox

like this??

DoCmd.OpenReport "forms!check_out_2_main!subForm.check_out_detail.SHIPMENT NO", acViewPreview, "", "", acNormal

But it not work...
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 19:11
Joined
Jan 14, 2017
Messages
18,257
NO

Assuming your subform control is actually called subform....

Code:
Dim strText As String
strText=Me.subForm.check_out_detail.Form.SHIPMENT NO

DoCmd.OpenReport strText, acViewPreview

You don't need the acNormal as its the default

OR to filter by a specific field and filter criteria, something like
Code:
DoCmd.OpenReport strText, acViewPreview, , "FieldName='" & FilterCriteria & "'"

HTH
 

naobao

Registered User.
Local time
Today, 11:11
Joined
Feb 13, 2014
Messages
76
NO

Assuming your subform control is actually called subform....

Code:
Dim strText As String
strText=Me.subForm.check_out_detail.Form.SHIPMENT NO

DoCmd.OpenReport strText, acViewPreview

You don't need the acNormal as its the default

OR to filter by a specific field and filter criteria, something like
Code:
DoCmd.OpenReport strText, acViewPreview, , "FieldName='" & FilterCriteria & "'"

HTH

THIS PART OF CODE IN RED

"strText=Me.subForm.check_out_detail.Form.SHIPMENT NO"

MAY BE HAVE MISTAKE?
 

isladogs

MVP / VIP
Local time
Today, 19:11
Joined
Jan 14, 2017
Messages
18,257
Apologies
As you have a space in Shipment No, it needs []

strText=Me.subForm.check_out_detail.Form.[SHIPMENT NO]
 

Users who are viewing this thread

Top Bottom