Results 1 to 8 of 8
  1. #1
    Rockb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    4

    How to click in a list box and send that data to a form that is tied to a query

    I have a form that contains a list box. What I want to do is when the user clicks on the list box the value of the item clicked on is sent to another form that is tied to a query that has criteria [enter number here] so that the value is automatically passed to that popup box.

    Hope that is clear enough.



    I have a database that started off 15 years ago as a stand alone database at a single site, then migrated to a replicated database across two sites, then went to a .mdb file on a web server that we interacted with via .asp pages. It is now time to put it on a Sharepoint server so I have to do back to using Access for everything and it has been a LONG time since I have worked with Access.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    The parameter has to reference the listbox control. Instead of [enter number here] in must be like [Forms!formname!listboxname].

    Otherwise, review http://allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Rockb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    4
    Quote Originally Posted by June7 View Post
    The parameter has to reference the listbox control. Instead of [enter number here] in must be like [Forms!formname!listboxname].

    Otherwise, review http://allenbrowne.com/ser-62.html
    I get an error Invalid Bracketing of Name

  4. #4
    Rockb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    4
    I went back and changed it to [forms]![formname]!
    [listboxname] and do not get an error but instead of displaying the form to select the item as I expected id just shows the text box to enter the desired item like it did before.

  5. #5
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Post up the SQL of your query , the form name and the listbox control name you want to use.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Use your actual form and listbox names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Rockb is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    4
    I went back and created a new DB with just a single table to hopefully simplify things to get the functionality that I want so I can then duplicate that on the full DB.

    I then created a Form with a combo box that is populated by one of the fields in that table. I have the On click event for that combo box pointed to a macro that opens a query with the following:

    SELECT Location.Location, Location.[E-Mail1], Location.[E-Mail2], Location.[E-Mail3], Location.TEL1, Location.TEL2, Location.TEL3, Location.TEL4, Location.TEL5, Location.TEL6, Location.TEL7, Location.TEL8
    FROM Location
    WHERE (((Location.Location)=[forms]![ContaceViewSelectLocation]![Combo0]));


    My desired end result is a report that is based on that query but thought it may be easier to start one step at a time and displaying the query results seemed to be the next step towards the desired result.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Did the query work? Is 'Contace' correct spelling?

    I NEVER use dynamic parameterized query. I prefer to set report filter when opening the report. Have you reviewed the Allen Browne link referenced earlier?

    VBA would look like:

    DoCmd.OpenReport "report name", , , "Location='" & Me.Combo0 & "'"

    Macro has equivalent functionality.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 01-09-2017, 04:56 PM
  2. Send data to form with query.
    By ThornofSouls in forum Programming
    Replies: 21
    Last Post: 11-24-2015, 01:35 AM
  3. Replies: 1
    Last Post: 09-07-2014, 10:15 PM
  4. Replies: 5
    Last Post: 05-20-2014, 11:51 AM
  5. Replies: 1
    Last Post: 09-30-2013, 11:47 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