Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-05-2019, 08:41 AM   #1
duncan17
Newly Registered User
 
Join Date: Jan 2019
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
duncan17 is on a distinguished road
Smile Macro to open different reports

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!

duncan17 is offline   Reply With Quote
Old 04-05-2019, 08:50 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,043
Thanks: 23
Thanked 529 Times in 517 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Macro to open different reports

Hi. I haven't used macros much but rather than use DLookup(), have you tried LookForRecord (I think that's what it's called)?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 04-05-2019, 08:55 AM   #3
duncan17
Newly Registered User
 
Join Date: Jan 2019
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
duncan17 is on a distinguished road
Re: Macro to open different reports

I will give that a try. Thanks!

duncan17 is offline   Reply With Quote
Reply

Tags
access , autoexec , if/then , macro function

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Reports as .pdf with Macro ertweety Excel 1 06-08-2012 02:24 AM
E-mail Reports from VBA or Macro maw230 Modules & VBA 2 12-18-2010 02:34 AM
Exporting reports using a macro StaphAreus Reports 1 08-23-2006 04:04 AM
Macro/VBA Code Open CSV file, save as xls, run excel macro elliotth123 Modules & VBA 7 11-08-2004 01:19 PM
Running Reports in a Macro (PDF) Ebeneezer Reports 1 10-06-2003 06:55 PM




All times are GMT -8. The time now is 01:50 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World