Setting Query Criteria based on SubForm Selection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Dell
    New Member
    • Dec 2010
    • 1

    Setting Query Criteria based on SubForm Selection

    Hi all,
    Extremely new to Access and VBA, I have been working my way through several books and sites, and I'm finally breaking down and crying for help.

    I am developing a contacts/messages/engagement/appointment tracking application for the CPA firm that I work for. I have made a main switchboard containing tabs with commands to open detail for records, but it is also important to be able to quickly view summarized data for outstanding engagements, calls and appointments. To do this I've created subforms on the switchboard displaying the pertinent info, I would like to be able to double click on one field (such as their number) and it display all phone calls from that specific client.

    I have written a query and edited the onclick event to do this, but it pops up with a dialog box to enter the clientID, I would like to filter the query automatically based on which client I click on. My question is, how can I reference the specific client clicked on in VBA to define the query's criteria?

    Does this seem like a decently efficient way to get what I'm asking for?

    Thank you to anyone who can shed some light on this.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    You can reference the contents of any control on an open form from your query in the criteria for the field in design mode of the query editor.

    Use
    Forms!FormName. ControlName


    Hope that helps

    Comment

    • Delerna
      Recognized Expert Top Contributor
      • Jan 2008
      • 1134

      #3
      Just some words of encouragement

      There are many ways to do what you require.
      Which way is best depends largely on the particulars of what you are doing.
      What works in one scenario may not in another.

      It is up to you as the developer to make that choice based on your experience, your knowledge and maybe some guidance from sites such as this.

      Ultimately, you can only work with what you know. The most important criteria, in my humble opinion, is that it works and that it performs acceptably for your client/users.

      That it is not "the most efficient" method matters little in practice providing the above are true.
      Sure, you should strive to be as efficient as possible but we must all start somewhere and we all grow as we gain experience.

      Comment

      Working...