Results 1 to 10 of 10
  1. #1
    accesshelpme is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    18

    details form open from listbox selection

    I have a listbox on my main form(named:customer editor). I want to be able to double click an item in the list box(name:list91) and bring up another form called productdetails. I want this to bring up the details of teh particular record in selected from the list.

    so i know
    in the listbox double click event:

    DoCmd.OpenForm "ProductDetails"

    but what else would i have to put in the code to ensure that it only opens up the details for that specific slection from the listbox

    any help is greatly appreciated!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Use the WHERE CONDITION argument:
    DoCmd.OpenForm "ProductDetails", , , "fieldname='" & Me.listbox & "'"

    If the field is not text type, remove the apostrophe delimiters, date type uses # delimiter.
    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
    accesshelpme is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    18
    ill try that

  4. #4
    accesshelpme is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    18
    ok, so it seems to be working, hwo would i add another where condition to this code?.........i have this so far
    DoCmd.OpenForm "ProductDetails", , , "Products='" & Me.List91 & "'"

    I also have a textbox that hold Client_Account_Name. I want to only show the record if its Client_Account_Name is equal to the one in this box.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    If both criteria will always be provided then simply:

    DoCmd.OpenForm "ProductDetails", , , "Products='" & Me.List91 & "' AND Client_Account_Name='" & Me.textbox & "'"

    Do clients have ID? Better to search on unique ID than 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.

  6. #6
    accesshelpme is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    18
    yes, it seems to be working ok, however if a customer has more then one instance of the same product...it will obviously show them all, and wont only show the selected record. There is a ID in the table that is unique to each instance of the product. Even without this ID being present in the listbox(list91) is there a way to make the where statemtn based on the id in the table related to the selected product in the list?....this would eliminate the problem of having more then one instance of the same product for a client

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Perhaps you also need the Order ID as criteria. Would each order have more than detail record for the same product?
    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.

  8. #8
    accesshelpme is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    18
    yes that is what the ID in the table is ...its essantially order ID. theres is an ID column, client_account_name, product column, vendor column, and details column. a client can have more then one instance of the same product. yet if there is numerous instances of the same product when i click one in the listbox it will open the details form with all of those records available. I want to go to that specific record related to the specific instance of a product i clicked in the listbox

  9. #9
    accesshelpme is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    18
    I would just add vendor to the where statement since it would likeely never happen that a client would have identicall products with identical vendors. But vendors is a multivalue field and can't be added to a where statement

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Why is vendors a multi-value field?

    I NEVER use multi-value field.

    Do you want to provide project for analysis? Follow instructions at bottom of my post.
    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. Deleting a ListBox Selection
    By dreamnauta in forum Programming
    Replies: 4
    Last Post: 01-27-2012, 03:14 PM
  2. Replies: 29
    Last Post: 02-13-2011, 01:21 AM
  3. Cancel Selection Event for ListBox
    By is49460 in forum Forms
    Replies: 2
    Last Post: 08-04-2010, 05:53 PM
  4. Cancel listbox selection
    By vba-dev in forum Access
    Replies: 0
    Last Post: 10-26-2009, 12:18 PM
  5. Replies: 0
    Last Post: 10-16-2008, 02:39 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