Results 1 to 3 of 3
  1. #1
    hartandsoul85 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    1

    Macro to open a report that includes certain dates?

    I have a bunch of reports that need to be printed, but only if they include a certain date. I want all of the dates to show up though.

    For example:

    There are 3 reports with a bunch of different dates in the bill date column.

    Reports A and B include the date 04/30/2012, along with a bunch of other dates.


    Report C does not include the date 04/30/2012.

    i want reports A and B to open since they include the date 04/30/2012, and I want all of the other records with other dates to show up on the reports along with records with a date of 04/30/2012. I do not want Report C to open at all.

    Please Help!

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You could create a Macro Action 'RunCode' - and give it the name of a Function Eg: 'Find_Date()' that you would create.

    In Function Find_Date(), you could use a DLookup() function to find the date in the dataset [Table/Query] on which your report is based.

    You can pass the Date that you are searching for to the Function or get the function to prompt for the Date - or - if it is always going to be the same Date - just hard-code it into the DLookup statement in the function.

    If DLookup finds that date in your data set - then you can issue a command - still in the Find_Date() function - to print/open the report:
    DoCmd.OpenReport . . .

    See this page for details on the syntax for DoCmd.OpenReport:
    http://msdn.microsoft.com/en-us/libr...ffice.12).aspx

    I hope this helps - but let us know if you need more help.

  3. #3
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    If me.[Bill date] = "04/30/2012" then
    docmd.openReport "YourReportName"
    'Or docmd.printOut
    else
    'do nothing
    exit sub
    'outta here
    end if

    Does that help ?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Copying fields includes column name
    By julioot in forum Access
    Replies: 14
    Last Post: 04-04-2012, 08:25 AM
  2. Macro to open URL from Field record
    By COiSman in forum Programming
    Replies: 3
    Last Post: 12-26-2011, 02:25 PM
  3. Replies: 0
    Last Post: 01-22-2011, 08:08 AM
  4. Replies: 0
    Last Post: 01-12-2011, 12:43 PM
  5. Replies: 20
    Last Post: 02-17-2010, 12:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums