Results 1 to 4 of 4
  1. #1
    Fiddler is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2018
    Posts
    15

    List box misbehaving


    Hi Folks, I have a simple, unbound list box on an unbound form. It has three columns. The rowsource is set to a query to obtain the employee id, name, and department. Some employees will be in two departments, so I wanted the user to be able to distinguish, so listed the department. The bound column is the employee id.

    The box was working fine, but all of a sudden, every time I click on it, it selects two values instead of one. The two values it selects are the two corresponding employee entries.

    Equally frustrating, a combo box I have set to pick up values dependent on the list box is now returning ALL values for the employee, rather than just the ones for the employee and department, like it was before.

    I have the on-click event of the list box set to requery the PO combo box, so when the employee changes, the data in the other box changes as well. I've also put this in the after-update event, as I wasn't sure which one would fire at the correct time.

    Thank you for any help. I hope this wasn't too garbled.

    It was all working just fine until it wasn't. Any ideas what is going on? I've double checked the property settings and it's still just "simple" list box (not multivalue). I've saved, closed, and reopened the form but it's still selecting two items.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    you only need 1 event....after-update event. An that only needs:
    Code:
    sub cboEmp_afterupdate()
       cboPO.requery
    end sub
    the sql for the cboPO looks at cboEmp
    select po from table where [empID] = forms!myForm!cboEmp

    the cboEmp must be assigned to [empID] via BOUND COLUMN.

    (i assume, but im not sure what PO box is pulling)

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As ranman256 said, the Requery only needs to be in one event. As to why your Listbox is now acting strange...

    Although we usually think of Forms, and even entire Databases, when we speak of corruption, Controls, such as Listboxes, can and do become corrupted, and seem particularly susceptible to this during app development.

    The test/cure for this is short and simple...delete and then re-create the Control.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Fiddler is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2018
    Posts
    15
    I removed the requery event from both places and this didn't affect the behavior of the list box at all; it still would select more than one item when I clicked. What did affect it was the setting of the cboPO rowsource. The rowsource was simply set to pull values based on the selection in the listbox. For some strange reason (I found other references to this problem) the cboPO was changing its rowsource without rhyme nor reason all on its own at random times throughout the program running. It would pull a query from the list of queries and use that instead of the query I had set up. When I would "fix" it back to the sql string it should be, the list box would work once, then the combo box would flip out and choose another rowsource for itself and cause the list box to not work. Very strange stuff. Anyway, after futzing with it for a while I redid the form entirely and now it seems to be working correctly. Thanks for looking at it.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2018, 11:00 PM
  2. Replies: 8
    Last Post: 12-13-2017, 10:38 AM
  3. Replies: 4
    Last Post: 08-22-2015, 12:30 PM
  4. Replies: 1
    Last Post: 04-21-2014, 08:00 AM
  5. Replies: 15
    Last Post: 11-20-2013, 04:30 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