Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a Specific Report with a Command Button on a Form 1

Status
Not open for further replies.

MattMeat

Programmer
Nov 6, 2001
38
US
Hello!

Hope everyone had a good weekend!

My question is probably a simple one for most experienced Access users. I just need to know how I can print a specific report by pressing a command button of a form. I've already created the button, the only problem is that it prints all the records in the report instead of the specific corresponding report page. I think i may have to use filtering but I'm not sure what the code is.

Thanks a lot,
Mattmeat




 
That's what the Where Clause aims.

You'll find them both in Macro
and in the VB code
DoCmd.OpenReport "Report_Name",,,Where_Clause

The content of the string WhereClause depends on the way you select the record(s) to br printed.
Its syntax is described in the Where clause of the SQL Select statement.

It could be something like:
"Customer_Number=25678", you obviously could build by something like:>>Where_Clause="Customer_Number=" & Current_Customer

When the value is alphanumeric, you have to build it that way
>>Where_Clause="Customer_ID='" & Current_ID & "'"

 
Thanks Lozere,

I think I understand what you are saying but I haven't been able to print the Current Record. Whatever record the Form is showing when the command runs is the one I want to appear in the report.

I tried Where_Clause=Current_Record but it was no good.

I appreciate your help.
Mattmeat

 
Hi, MattMeat, I am working with the German Version of Access so maybe there will be strange words I use:
Create a Macro with the command: 'open report'. In the field 'condition' in the bottom (it should be the fourth and last field), you write: [Field]=[Forms]![Name of form].[Field].
Field must be the record identifyer.
Note: if you want to display a record in the report you just created in the form, before using 'open report' you will have to insert in your macro: 'DoCommand' (in German it is AusführenBefehl with the Command 'actualise' (in German: Aktualisieren)

I am sorry for maybe creating more problems (linguistic ones) instead of solving tnem.

Bye, Yvonne
 
YvonneNina,

Not only did you solve my Access problem, but your words gave me a great idea for a song I could write. I thank you very much.

Mattmeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top