Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    I am using Access 2007, shouldn't matter much for my question though.

    I am using a DB that has many different fields in one table. I have searches built to search for results from the table and return them in a form I designed. The searches ask for the user to enter the parameter and they work just fine. Things are also displayed just fine.

    My problem is that when the "Show Report" or "Print Report" command button is pressed it asks for the user entered parameter again. If they enter the same thing the results are the same and everything works as planned, but I would like to make it so the user doesn't have to enter the parameter again and it is stored and used again automatically. I haven't used VB before but I have done a lot of C++ and have about a week of time clocked in Access so my knowledge isn't quite there yet for some of the things.

    I am sure there is an easy solution to this using VB, in C++ I would just store the parameter in a var and call that when I need it. Any help would be very appreciated!

    Thanks, Brandon

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    It's not really necessary to use VBA to do what you are describing - instead you can use the values in the form as your criteria for the data source for the report. To do that you reference the values as
    Forms!FormsName!ControlName in the data source of the report. Another option is to use the open criteria when you use code to open the report from the form. You can create an example of that sort of code by using the wizard to open up a report on a specific record where the report would normally show all records. And either approach is independant of the verison of Access you are using.
    Wendell

  3. #3
    New Lounger
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your response Wendell,

    but I am having trouble grasping Access' syntax or something. I tried
    Forms![POcontractNUM]![PO#/CONTRACT#] And to be honest with you. I have no idea if I have it in the right spot or anything. I am still trying to figure out Access and all of its bells and whistles. I am putting it into the record sorce field on the data tab exactly as I pasted here. Thanks in advance for any help and sorry for my lack of knowledge on the subject.

    Thanks,
    Brandon

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The record source of the report should be the name of a query based on your table.
    In the design of the query, use the expression [Forms]![POcontractNUM]![PO#/CONTRACT#] in the criteria line for the relevant field (column).
    When the report is opened from your form, it will automatically use the value of the PO#/CONTRACT# control on your form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •