I have worked this for too long, now and so I humbly submit this simple question that eludes me...
I have a list box "listSimDiscrID" that is populated with a limited list from a table. The information I need form this list is (1) the discrepancy ID and (2) the title of the discrepancy. I had this list box working fine and it would store the DiscrID to the control data that the list box control was bound to, AND it would store the discrepancy title in the txtSimComments textbox on the form (using the _afterUpdate event and having Me.txtSimComment=listSimDiscrID.Column(2).
However, I had to go and ruin a good thing by trying to question the user if they return to the form and try to change the discrepancy for the event. I added the following msg box (derived from another EE thread):
Private Sub listSimDiscrID_BeforeUpdate(Cancel As Integer)
If MsgBox("Do you want to change sim available code?", vbOKCancel) = vbOK Then
Me.SimDiscrID = listSimDiscrID.Column(0) 'this line added to try and get listbox to update
Me.txtSimComment = listSimDiscrID.Column(2) 'this line always works fine
Me.txtSimComment = Me.txtSimComment.OldValue
The problem with above code: I click on the listbox item and the msg box pops up just fine...I click "OK" in msg box and the comments box lists the new title great...but the listSimDiscrID listbox does not save the change to the bound countrol data until the pop-up is closed?
If that is not clear, here is an example - - - say there is already a discrepancy for this record on the form (DISCREPANCY#1), and a user clicks on a new discrepancy in the list and says, "ok" (discrepancy #2)...the code does not change the discrepancy until the form is closed!?! So, if the user then changes his mind and clicks on a different discrepancy in the list (DISCREPANCY#3),and when the msg box asks "do you want to change this discrepancy? he decides, no, he wants to keep it at the previous (DISCREPANCY#2) so he clicks, Cancel on msg box...the comment box reverts back to (DISCREPANCY#1) which leaves me with a discrepancy ID that is not aligned with its correct title?!?
How do I get the listbox to update its value from the "OK" selection on the msg box?
Long discription/question to what has to be a short answer.