Results 1 to 4 of 4
  1. #1
    Kevin.Murad is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    2

    Using expressions and current ID of a form to create a query and print a report.

    Hello all,
    I am new to this forum as well as Access as a whole. I do have some knowledge and have created macros and expressions to automate functions in my database but I do need some help.

    I want to have Access run a query, open a report, and print the report based on the ID number of the form that I have open. Is this possible?

    The situation would be, I have a form that uses the the primary key as a record number. After I enter the data into the form, with the form open I want to add a button to open and print a report of the current record number.

    Thanks in advance

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    Yes this is routine. first - when you open a report it defacto runs its record source query (if it's record source is a query...) so you don't need to explicitly fire the query.

    There are 2 approaches:
    Query: in the query that is the record source of the report - "call" the ID value from the form by putting it in the criteria of the query. the syntax is: Forms!FormName.ControlName

    Opening Argument: look into the Opening Argument - if you are using Macros vs VBA will differ - but the concept is the same: and in the 'Where' section of the Opening Argument you enter the form's control name that holds the id.

    Hope this helps

  3. #3
    Kevin.Murad is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    2
    NTC,

    Thank you for the response, I tried the code but I must be missing something. When I run the query a window comes up wanting me to enter the record (ID) number that I want pulled up.

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    that means that your criteria in the query cannot be found. it could be a typo or a misunderstanding.... presuming you are using: Forms!FormName.ControlName

    then double check that you have the correct names.....

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

Similar Threads

  1. Print Report from Current Record
    By hnkford in forum Reports
    Replies: 15
    Last Post: 05-22-2015, 08:08 AM
  2. Replies: 7
    Last Post: 08-09-2012, 10:18 AM
  3. Print current record to a report
    By drawc in forum Access
    Replies: 2
    Last Post: 01-15-2012, 12:48 AM
  4. Replies: 5
    Last Post: 10-26-2011, 02:59 PM
  5. How to create and print unique report for each entry???
    By Stelios Panayides in forum Reports
    Replies: 2
    Last Post: 10-05-2009, 08:54 AM

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