Form filter then print report

G

Golfinray

I would like to have a little form that filters by selection a particular
record, then have a command button that selects that record in a report and
then prints the record. Or is there a better way? I can get the form and
filter to work, but how do you do the calling of the record in the report and
then print only that one record? Thanks so much!!!!
 
K

Klatuu

Use the Where argument of the OpenReport method. You identify a field that
will have a unique value in the field. This is usually the table's primary
key. It is the fourth argument of the method:

Docmd.OpenReport "ReportName", , , strWhere

Now, to get the value in the strWhere variable, you may consider using a
combo box on you form that will return the value. So strWhere needs to look
like an SQL WHERE clause without the word where. Say your report's recordset
primary key field is named ClientID and you have a combo on the form that
returns ClientID and ClientName and the ClientID column is the bound column.
it would be like:

strWhere = "[ClientID] = " & Me.cboClientSearch
 
G

Golfinray

As usual, Dave, "You the man!"

Klatuu said:
Use the Where argument of the OpenReport method. You identify a field that
will have a unique value in the field. This is usually the table's primary
key. It is the fourth argument of the method:

Docmd.OpenReport "ReportName", , , strWhere

Now, to get the value in the strWhere variable, you may consider using a
combo box on you form that will return the value. So strWhere needs to look
like an SQL WHERE clause without the word where. Say your report's recordset
primary key field is named ClientID and you have a combo on the form that
returns ClientID and ClientName and the ClientID column is the bound column.
it would be like:

strWhere = "[ClientID] = " & Me.cboClientSearch

--
Dave Hargis, Microsoft Access MVP


Golfinray said:
I would like to have a little form that filters by selection a particular
record, then have a command button that selects that record in a report and
then prints the record. Or is there a better way? I can get the form and
filter to work, but how do you do the calling of the record in the report and
then print only that one record? Thanks so much!!!!
 

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

Top