Being new to Access I’m not aware of a query, control source expression or other method to select an alternate field based on the value of a third field so I assume code is required. I need this field selection operation for input to a report.
Each record has a primary field (Customer), an alternate field (Bill To) and a “group” field (Buy Group). IF the group field is blank then the alternate field is blank also. In other words, there is no Bill To if the record does not have a Buy Group. By default, the report (actually an invoice) must show the Customer and associated address, city, etc. if the Buy Group is blank. What is needed however is the replacement of the Customer field if and only if, the record has a Buy Group field with a value. If the Buy Group field has a value then there will be a Bill To field with a value. Then the Customer value must be replaced with the Bill To value and its associated address, city, etc.
The RAW logic is simple:
IF (ISNULL[Buy Group]) THEN
[Customer]
ELSE
[Bill To]
END IF
Obviously there’s an Address, and City-State-Zip that is tied to Customer and a different Address and City-State-Zip that is tied to Bill To.
The report/invoice is fed from a query which has the Customer, Buy Group and Bill To fields already determined. I assume this macro should run upon opening the report/invoice for a chosen record. I’m also not sure where to install the macro in order to implement/run it.
I’m using Access 2010 but I started with an Access 2007 template.
I hope someone will show me the code necessary to do this. Thanks
Each record has a primary field (Customer), an alternate field (Bill To) and a “group” field (Buy Group). IF the group field is blank then the alternate field is blank also. In other words, there is no Bill To if the record does not have a Buy Group. By default, the report (actually an invoice) must show the Customer and associated address, city, etc. if the Buy Group is blank. What is needed however is the replacement of the Customer field if and only if, the record has a Buy Group field with a value. If the Buy Group field has a value then there will be a Bill To field with a value. Then the Customer value must be replaced with the Bill To value and its associated address, city, etc.
The RAW logic is simple:
IF (ISNULL[Buy Group]) THEN
[Customer]
ELSE
[Bill To]
END IF
Obviously there’s an Address, and City-State-Zip that is tied to Customer and a different Address and City-State-Zip that is tied to Bill To.
The report/invoice is fed from a query which has the Customer, Buy Group and Bill To fields already determined. I assume this macro should run upon opening the report/invoice for a chosen record. I’m also not sure where to install the macro in order to implement/run it.
I’m using Access 2010 but I started with an Access 2007 template.
I hope someone will show me the code necessary to do this. Thanks