Generate a report from unbound text box and parameter query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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

.
 

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

Back
Top