Conditional Report Viewing

  • Thread starter Thread starter Steve T
  • Start date Start date
S

Steve T

Here is what I am trying to do. I have reports named
rptPurchaseOrderSoldToAddress, rptPurchaseOrderShipToAddress, and
rptPurchaseOrderFabric

Currently we have 3 different buttons on the purchase order form and we have
to remember which one to push

We want to have one button that says "Print Purchase Order" and have access
look at the values in different fields and depending what is in those
fields, it will pick the correct report to print. There are 3 conditions
that have to be evaluated.

If [ShipTo] = "Same" and [VendorShipAddress] = "Choose A Vendor" then print
rptPurchaseOrderBillToAddress

If [ShipTo] <> "Same" and [VendorShipAddress] = "Choose A Vendor Ship
Address" then print rptPurchaseOrderShipToAddress

If [VendorShipAddress] <> "Choose a Vendor Ship Address" then print
rptPurchaseOrderFabric

Hope that makes sense

Steve T
 
Steve said:
Here is what I am trying to do. I have reports named
rptPurchaseOrderSoldToAddress, rptPurchaseOrderShipToAddress, and
rptPurchaseOrderFabric

Currently we have 3 different buttons on the purchase order form and we have
to remember which one to push

We want to have one button that says "Print Purchase Order" and have access
look at the values in different fields and depending what is in those
fields, it will pick the correct report to print. There are 3 conditions
that have to be evaluated.

If [ShipTo] = "Same" and [VendorShipAddress] = "Choose A Vendor" then print
rptPurchaseOrderBillToAddress

If [ShipTo] <> "Same" and [VendorShipAddress] = "Choose A Vendor Ship
Address" then print rptPurchaseOrderShipToAddress

If [VendorShipAddress] <> "Choose a Vendor Ship Address" then print
rptPurchaseOrderFabric


Try this:

If [VendorShipAddress] <> "Choose a Vendo" Then
DoCmd.OpenReport "rptPurchaseOrderFabric"
Else
If [ShipTo] = "Same" Then
DoCmd.OpenReport "rptPurchaseOrderBillToAddress"
Else
DoCmd.OpenReport "VendorShipAddress"
End If
End If

BUT, having three separate reports strikes me as unecessary,
if all you want is to display a different address.
 
Marshall Barton said:
Steve said:
Here is what I am trying to do. I have reports named
rptPurchaseOrderSoldToAddress, rptPurchaseOrderShipToAddress, and
rptPurchaseOrderFabric

Currently we have 3 different buttons on the purchase order form and we
have
to remember which one to push

We want to have one button that says "Print Purchase Order" and have
access
look at the values in different fields and depending what is in those
fields, it will pick the correct report to print. There are 3 conditions
that have to be evaluated.

If [ShipTo] = "Same" and [VendorShipAddress] = "Choose A Vendor" then
print
rptPurchaseOrderBillToAddress

If [ShipTo] <> "Same" and [VendorShipAddress] = "Choose A Vendor Ship
Address" then print rptPurchaseOrderShipToAddress

If [VendorShipAddress] <> "Choose a Vendor Ship Address" then print
rptPurchaseOrderFabric


Try this:

If [VendorShipAddress] <> "Choose a Vendo" Then
DoCmd.OpenReport "rptPurchaseOrderFabric"
Else
If [ShipTo] = "Same" Then
DoCmd.OpenReport "rptPurchaseOrderBillToAddress"
Else
DoCmd.OpenReport "VendorShipAddress"
End If
End If

BUT, having three separate reports strikes me as unecessary,
if all you want is to display a different address.

Well, I have currently have 3 separate tables with three separate queries to
run the reports. Each table stores the addresses (name, city, state, zip).
How would I go about only having one report to display different addresses?

Steve T
 
Steve said:
Steve said:
Here is what I am trying to do. I have reports named
rptPurchaseOrderSoldToAddress, rptPurchaseOrderShipToAddress, and
rptPurchaseOrderFabric

Currently we have 3 different buttons on the purchase order form and we
have
to remember which one to push

We want to have one button that says "Print Purchase Order" and have
access
look at the values in different fields and depending what is in those
fields, it will pick the correct report to print. There are 3 conditions
that have to be evaluated.

If [ShipTo] = "Same" and [VendorShipAddress] = "Choose A Vendor" then
print
rptPurchaseOrderBillToAddress

If [ShipTo] <> "Same" and [VendorShipAddress] = "Choose A Vendor Ship
Address" then print rptPurchaseOrderShipToAddress

If [VendorShipAddress] <> "Choose a Vendor Ship Address" then print
rptPurchaseOrderFabric


Try this:

If [VendorShipAddress] <> "Choose a Vendo" Then
DoCmd.OpenReport "rptPurchaseOrderFabric"
Else
If [ShipTo] = "Same" Then
DoCmd.OpenReport "rptPurchaseOrderBillToAddress"
Else
DoCmd.OpenReport "VendorShipAddress"
End If
End If

BUT, having three separate reports strikes me as unecessary,
if all you want is to display a different address.

Well, I have currently have 3 separate tables with three separate queries to
run the reports. Each table stores the addresses (name, city, state, zip).
How would I go about only having one report to display different addresses?


Three tables? That can be overcome by using a query for the
report's record source. The query would Join the tables on
an appropriate field (Vendor ID???). Once you have all the
potential data in one (virtual) place, you can select which
part of it to use.

A possibly simpler alternative to that might be for the
report to use code somewhat like the above to determine
which table to get the address from. Use the Format event
of the section containing the address text box. The code
would be vaguely like:

If [VendorShipAddress] <> "Choose a Vendo" Then
txtaddr = DLookup("addr","Fabric", "keyfield=" & Me.Key)
Else
If [ShipTo] = "Same" Then
txtaddr = DLookup("addr","BillToAddress", _
"keyfield=" & Me.Key)
Else
txtaddr = DLookup("addr","ShipAddress", _
"keyfield=" & Me.Key)
End If
End If

I would need more details before I could provide more
specific advice.
 
Marshall Barton said:
Steve said:
Steve T wrote:

Here is what I am trying to do. I have reports named
rptPurchaseOrderSoldToAddress, rptPurchaseOrderShipToAddress, and
rptPurchaseOrderFabric

Currently we have 3 different buttons on the purchase order form and we
have
to remember which one to push

We want to have one button that says "Print Purchase Order" and have
access
look at the values in different fields and depending what is in those
fields, it will pick the correct report to print. There are 3
conditions
that have to be evaluated.

If [ShipTo] = "Same" and [VendorShipAddress] = "Choose A Vendor" then
print
rptPurchaseOrderBillToAddress

If [ShipTo] <> "Same" and [VendorShipAddress] = "Choose A Vendor Ship
Address" then print rptPurchaseOrderShipToAddress

If [VendorShipAddress] <> "Choose a Vendor Ship Address" then print
rptPurchaseOrderFabric


Try this:

If [VendorShipAddress] <> "Choose a Vendo" Then
DoCmd.OpenReport "rptPurchaseOrderFabric"
Else
If [ShipTo] = "Same" Then
DoCmd.OpenReport "rptPurchaseOrderBillToAddress"
Else
DoCmd.OpenReport "VendorShipAddress"
End If
End If

BUT, having three separate reports strikes me as unecessary,
if all you want is to display a different address.

Well, I have currently have 3 separate tables with three separate queries
to
run the reports. Each table stores the addresses (name, city, state,
zip).
How would I go about only having one report to display different
addresses?


Three tables? That can be overcome by using a query for the
report's record source. The query would Join the tables on
an appropriate field (Vendor ID???). Once you have all the
potential data in one (virtual) place, you can select which
part of it to use.

A possibly simpler alternative to that might be for the
report to use code somewhat like the above to determine
which table to get the address from. Use the Format event
of the section containing the address text box. The code
would be vaguely like:

If [VendorShipAddress] <> "Choose a Vendo" Then
txtaddr = DLookup("addr","Fabric", "keyfield=" & Me.Key)
Else
If [ShipTo] = "Same" Then
txtaddr = DLookup("addr","BillToAddress", _
"keyfield=" & Me.Key)
Else
txtaddr = DLookup("addr","ShipAddress", _
"keyfield=" & Me.Key)
End If
End If

I would need more details before I could provide more
specific advice.

Oh, I see what it is doing. One query to pull everything and then let the
report deal with it and put it in the correct place. I will give it a try
and see if I can get it to do what I want it to do. Thanks for the
guidance. I will let you know what I come up with.
 
Back
Top