Macro to open different reports (1 Viewer)

duncan17

Registered User.
Local time
Today, 09:34
Joined
Jan 29, 2019
Messages
10
I have an access db that runs an autoexec macro upon opening. The macro imports a csv file into a table, opens a report, then prints the report to the set printer for said report. Currently for each location this db is being used, the db is exactly the same but the printer for the report is different (automatically printing parts labels on a usb label printer). Instead of having 7 different "almost identical" db's, I want to have one db with 7 reports, which would be set to the location's label printer. I have a c# program that runs in the foreground and prints the labels with Access in minimized mode, and I am passing in the users location (from Active Directory) into another table in the db. What I am trying to do is create an If/Then step in my autoexec macro that will read that one record from the "Location" table (gets overwritten each time) and will open a specific report to be printed based on the location. When I try to setup the macro if/then statement using DLOOKUP, it tells me that it cannot find the field in the table. Does anyone have a better solution or know how to use DLOOKUP in an IF/THEN statement to open a specific report if the value found is equal to specific value? Any help would be greatly appreciated! :)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:34
Joined
Oct 29, 2018
Messages
21,358
Hi. I haven't used macros much but rather than use DLookup(), have you tried LookForRecord (I think that's what it's called)?
 

duncan17

Registered User.
Local time
Today, 09:34
Joined
Jan 29, 2019
Messages
10
I will give that a try. Thanks!
 

Users who are viewing this thread

Top Bottom