Results 1 to 2 of 2
  1. #1
    Slategrey252 is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2009
    Posts
    1

    I want to automatically pass a value to a query

    I have a form and a sub form. Lets call the form personal details and the subform contract details. Linked in a one to many relationship, personal to contract.

    Now the form is open with the personal details being displayed and the sub form showing all the contracts for that person.

    Now how do I pass a value to a query to print out the subform details automatically in a report, i.e without having to type something into a dialog box.

    I want to click the button and let it do the work.

    Any help would be appreciated as with my limited access skills, this quite frankly is "doing my head in"

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Create a report based on the subform with all the required fields. Then create a button to open the report and put some code on the OnClick event which will be something like this:

    stDocName = "ContractsReport"
    stWhere = "PersonRef = '" & Me!PersonRef & "'"
    DoCmd.OpenReport stDocName, acPreview, , stWhere

    What this does is filter the report to whichever person you have on the screen.

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

Similar Threads

  1. Replies: 0
    Last Post: 07-30-2009, 12:40 PM
  2. Can I pass "sort by" using DoCmd.OpenReport
    By alsoto in forum Reports
    Replies: 3
    Last Post: 04-16-2009, 08:11 PM
  3. 90 days in the pass - Date help wanted
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 01-26-2009, 07:13 AM
  4. pass a variable to the MsgBox function
    By 3dmgirl in forum Programming
    Replies: 2
    Last Post: 04-19-2007, 07:14 AM
  5. Replies: 0
    Last Post: 03-19-2006, 11:52 PM

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