Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004

    Unanswered: Passing Values To A Control Box Query

    Hey All. I have to compliment everyone here. This place is amazing. It has helped me so much. Now I have a question though. I have a form based on a query. You pull up the form, the query runs and brings back the camper information so you can enter details about a incident. I added a comand button on the header to run a report based on a query to bring up the family contact information, the query run on the last name. Which is in the header of the form. I want to be able to push the button to run the report for the family info and pass the last name to the query so no user interaction is required. Any help would be much appreciated.


  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    For starters, consider using autonumbers for your primary keys. What happens when two families have the same last name?

    Secondly, you can pass the value as part of the where clause when open the report:

    DoCmd.OpenReport "reportName", acPreview, , "[keyfield] = '" & keyfield.value & "'"

    Note that if you change your primary keys over to a numeric datatype, you'll have to remove the single quotes around the value you pass.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jun 2004
    Seattle, WA
    I assume you have like "last name" for a field. In the query you can use something like...

    Put this in the criteria field under LastName...You do need the [forms]! part first. My syntax may not be right on, but pretty close
    My Blog

  4. #4
    Join Date
    Jul 2004


    I am using numbers for my primary keys. I am a newbie, but am learning. I know absolutely no VBA. Thats where this forum is coming in handy. I am actually very proud of how far I came from the begining of this summer. I wrote this database, nothing was related. Right now I am working on the one for next year and everything is being tied togethor. Same Teach Yourself Access in 24 Hours is a great book. The book plus you guys, have taught me so much. Thanks!

Posting Permissions

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