Generate a report from unbound text box and parameter query

R

Raj

I have a form that is used to preview or print reports. I would like to add
an unbound text box on the form and when the user enters a code have it pull
the data from a parameter query and display the data in a report. Can
someone please direct me where i might be able to find a way to do this?
Thank you
 
M

Marsela

Use the Criteria:
1. Suppose that You have a Button: CmdPreviewPrint
2. Unbound Text Box: TxtCode
3. CodeId is the name of field on the table (from which
you create the query). If this name (CODEID) is the only
name in all tables so the code below should work,
otherwise if you have more than two tables with the same
field name you need to specify the table name on the code
below.
Also this code you can put direct in AfterUpdate event of
Your unbound Text Box.

The Event on Command Button

Private Sub CmdPreviewPrint_Click()
dim pstrcriteria as string
pstrcriteria ="[CodeId}=[forms]![formname]!me!txtCode"

DoCmd.OpenReport "ReportName", acViewPreview, ,
pstrcriteria
end sub

Thanks
Marsela
 
R

Raj

Marsela,
Thank you!

Marsela said:
Use the Criteria:
1. Suppose that You have a Button: CmdPreviewPrint
2. Unbound Text Box: TxtCode
3. CodeId is the name of field on the table (from which
you create the query). If this name (CODEID) is the only
name in all tables so the code below should work,
otherwise if you have more than two tables with the same
field name you need to specify the table name on the code
below.
Also this code you can put direct in AfterUpdate event of
Your unbound Text Box.

The Event on Command Button

Private Sub CmdPreviewPrint_Click()
dim pstrcriteria as string
pstrcriteria ="[CodeId}=[forms]![formname]!me!txtCode"

DoCmd.OpenReport "ReportName", acViewPreview, ,
pstrcriteria
end sub

Thanks
Marsela
-----Original Message-----
I have a form that is used to preview or print reports. I would like to add
an unbound text box on the form and when the user enters a code have it pull
the data from a parameter query and display the data in a report. Can
someone please direct me where i might be able to find a way to do this?
Thank you

.
 
Top