Results 1 to 7 of 7
  1. #1
    SaskiFX is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    30

    Question Using a listbox to display query information

    I'm trying to get a listbox to display results of a query that are only related to the current record being viewed.

    I have a form (setup as a continuous form) that displays a vendor table. I have a query setup to reference what parts a vendor supplies, and I would like those results to be visible on the form. I would use a subform to make this happen, but if I try and drop a subform on the main form, it says it won't do it with a continuous form. So, the listbox. I copied my form, dropped in the subform, and took a copy of the SQL statement. I then took that SQL statement and dropped it on the Row Source of the unbound listbox. I do get a return of Parts and Prices, but its the whole list, not just a list for the currently displayed vendor. My SQL is currently thus:

    Code:
    SELECT tblPrice.[Part Number], tblPrice.Cost, tblPrice.[Price Date], tblPrice.[Bulk Discount], tblVendors.[Vendor Name]
    FROM tblVendors INNER JOIN tblPrice ON tblVendors.[VendorID] = tblPrice.[VendorID];
    I have tried to wrap my head around it, and I'm stuck. GoogleFu has also failed me, as I can't find something quite on point to what I'm doing.

    Any suggestions?



    Thanks!

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I do not see a WHERE clause in the query.
    Example:
    Code:
    SELECT tblPrice.[Part Number], tblPrice.Cost, tblPrice.[Price Date], tblPrice.[Bulk Discount], tblVendors.[Vendor Name]
    FROM tblVendors INNER JOIN tblPrice ON tblVendors.[VendorID] = tblPrice.[VendorID]
    WHERE tblVendors.[VendorID] = forms!MyForm.cboVendorID;
    Change to your field and control names.......

  3. #3
    SaskiFX is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    30
    That worked great! For anyone else looking for the info, I added the WHERE clause and Access changed it to:
    Code:
    SELECT tblPrice.[Part Number], tblPrice.Cost, tblPrice.[Price Date], tblPrice.[Bulk Discount], tblVendors.[Vendor Name]
    FROM tblVendors INNER JOIN tblPrice ON tblVendors.[VendorID] = tblPrice.[VendorID]
    WHERE (((tblVendors.VendorID)=[forms]![frmVendorBrowser].[VendorID]));
    Then on the Form properties, I set the On Current event to lstParts.Requery so it would update the listbox as I clicked around.

    Thanks again for the help.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Great!

    Ready to mark this solved??

  5. #5
    SaskiFX is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    30
    Yes please. I actually hunted around to find out how to do so, but I was unsuccessful.

    I figured it might be under the Forum Support link up top, but its a dead link.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It is in the 2nd green (on my computer) header under TREAD TOOLS dropdown, the last selection.

  7. #7
    SaskiFX is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    30
    Perfect, thanks!

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

Similar Threads

  1. Replies: 2
    Last Post: 01-17-2013, 01:25 AM
  2. Replies: 19
    Last Post: 11-01-2012, 08:03 AM
  3. Display Query Information on a form
    By srmezick in forum Forms
    Replies: 2
    Last Post: 12-15-2011, 09:24 AM
  4. Display RESULTS of Query into LISTBOX?
    By taimysho0 in forum Programming
    Replies: 6
    Last Post: 11-22-2011, 10:05 PM
  5. Need help with database to display vehicle information
    By jlmnjem in forum Database Design
    Replies: 1
    Last Post: 07-25-2006, 08:48 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