ListBox confusion...

JaedenRuiner

Registered User.
Local time
Today, 01:22
Joined
Jun 22, 2005
Messages
154
Okay,

I have a listbox that populates it's values from a table. Upon the click() event, I run a script to determine the current record for the rest of the form. One of which is an TextBox bound a field in the table the ListBox is populated from.

I store the old values in the Form_Current() method, and allow the user to change the values in the TextBox, and upon textbox_change() I enable an 'Apply' command button.

When the Apply Button is pushed, I set the "saved" data to the actual current data (since the control is bound to a record field), and thus the changes are fully applied. However, I cannot seem to get the ListBox to update it's 'text' display to represent the changed value from the textbox.
I have tried ListBox.requery, but it doesn't work instantly...it sometimes is delayed until I change "apply" a new set of changes.

Why is this?

Specifics:
Table
AreaID (AutoNumber)
Area (Text)

Query
Table.*

AreaList.RowSource = Table
AreaEdit.ControlSource = Area

Code:
Private Sub AreaEdit_Change()
   Dim St As String
      St = AreaEdit.Text
        Debug.Print "Chg Text: " & St
      Call UpdateChanges(True)
End Sub

Private Sub UpdateChanges(ByVal Value As Boolean)
   ChangesMade = Value
   ApplyBtn.Enabled = ChangesMade
End Sub

Private Sub ApplyBtn_Click()
   AreaList.SetFocus  'this is because you can't disable a control (the applybtn) when it has the focus
   AreaList.Requery  '<==== THis is supposed to repopulate the listbox, but it doesn't do it.
   Call Form_Current 'this just stores the current values of the actual record into temp variables
   Call UpdateChanges(False)
End Sub

Thanks

Jaeden "Sifo Dyas" al'Raec Ruiner
 
I'm having a similar issue with refreshing my combo box...

I have a form with several subforms and combo boxes. One of my combo boxes has a list of tests populated from a query. When the user adds and/or deletes a test in my subform, I want the tests combo box to refresh with the change.

I have tried ListBox.requery, but it doesn't work instantly...it sometimes is delayed until I change "apply" a new set of changes.

Same thing is happening with me.


I'm not using a button like JaedenRuiner, so it has to be an automatic population of the combo box.

Anyone have any ideas :confused:

Thanks,
dbnewbie
 
Last edited:
Try this:

Private Sub ApplyBtn_Click()
Docmd.RunCommand acCmdSaveRecord ' <<< add this line
AreaList.SetFocus 'this is because you can't disable a control (the applybtn) when it has the focus
AreaList.Requery '<==== THis is supposed to repopulate the listbox, but it doesn't do it.
Call Form_Current 'this just stores the current values of the actual record into temp variables
Call UpdateChanges(False)
End Sub

Let me know if it works.
 

Users who are viewing this thread

Back
Top Bottom