Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Location
    Wetaskiwin, Ab, Ca
    Posts
    16

    Unanswered: Listbox selection control

    What I have is a situation where I would like to have a listbox that is populated by a query of a table. When an item is double clicked, I want an update query to be run on the record that contains that information and then have the listbox update itself as that item would now be removed from it's source.

    For an actual example, the production facility where I am employed gets some raw materials on railcars. All the cars are to be tracked in a database. I have a form with a listbox on it that querys the table storing the info on railcars for ones that are onsite and full. What I want is when a record for a railcar in the listbox is double clicked, it's status to be changed to empty and the list should be updated to show that it is no longer full and on-site.

    Is this possible or am I barking up the wrong tree?

    All help is appreciated,
    Kevin Johnson

  2. #2
    Join Date
    Sep 2003
    Location
    Wetaskiwin, Ab, Ca
    Posts
    16
    Nevermind, I just figured it out. it was the stupidest little thing making it not work.

  3. #3
    Join Date
    Sep 2003
    Location
    Wetaskiwin, Ab, Ca
    Posts
    16
    Darn it, still need help with this. Thought I had it working, but I didn't have enough test data in the list. With more data it does the action to all the items.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ??can you capture the dblclick?

    ??can you put up a msgbox in the dblclick event that shows the correct railcarID (or whatever field you are going to use to find the record to update)?

    if yes to these two, what doesn't work?

    izy

  5. #5
    Join Date
    Sep 2003
    Location
    Wetaskiwin, Ab, Ca
    Posts
    16
    When I double click on the item, it will perform the action on all items in the list, not just the one selected. Can the item selected be sent to an update query or does everything have to be done inside the event code?

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    that was the point of my second question.

    you need to work out which record needs editing: the simplest way to see if you are headed in the right direction is to try to show the railcarID in a msgbox in the dblclick event.

    best is for your listbox to have [railcarID] as the bound column, then in the dblclick event:
    msgbox "I am working on record: " & listBoxName.value ' should work

    once you can get the correct [railcarID] into the message box, you can also get it into an update query (or SQL statement etc etc).

    the query criteria:
    [Forms]![theFormName]![listBoxName]

    and now you can run the query from the dblclick event:
    docmd.setwarnings false 'if you don't want to see warning messages
    docmd.openquery "nameOfTheQuery"
    docmd.setwarnings true
    if this is an update query, only the matching record gets updated.

    ...substituting the real names for listBoxName, railcarID, theFormName, nameOfTheQuery of course!

    and delete the msgbox line once it all works for you

    izy

  7. #7
    Join Date
    Sep 2003
    Location
    Wetaskiwin, Ab, Ca
    Posts
    16
    After having to work on another task for a month, I finally got back to working on the DB. I found my problem was that I was binding to the wrong column and therefore not getting the right railcarID.

    Thanks for your help!

Posting Permissions

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