Run different reports based on field values?

  • Thread starter Thread starter Thomas
  • Start date Start date
T

Thomas

In Access 2000 I have a database using a form for data
entry. I have it set up so that you can press a command
button to print a letter (Report) for the record that is
currently displayed. However, there are 3 categories of
items that each require a differently formatted letter.
Thus I have 3 reports for each type.

Rather than using 3 separate buttons based on the category
to print the correct report (which would have to be
manually selected), can I set it up so that with one
button it will run the correct report based on the the
value in the category field?

Ie: If Category = Car, then Report 1
If Category = Truck, then Report 2

I am stumped on how to do this.
Thanks!
 
Thomas said:
In Access 2000 I have a database using a form for data
entry. I have it set up so that you can press a command
button to print a letter (Report) for the record that is
currently displayed. However, there are 3 categories of
items that each require a differently formatted letter.
Thus I have 3 reports for each type.

Rather than using 3 separate buttons based on the category
to print the correct report (which would have to be
manually selected), can I set it up so that with one
button it will run the correct report based on the the
value in the category field?

Ie: If Category = Car, then Report 1
If Category = Truck, then Report 2

Change the buttons code to include:

If Category = "Car" Then
strDocName = "Report 1"
ElseIf Category = "Truck" Then
strDocName = "Report 2"
Else
strDocName = "Report 3"
End If

DoCmd.OpenReport strDocName, . . .
 
Back
Top