I have a form that has a combo box and a list box on it. From the GUI of the form, I have set the list box control source = to a query. From the combobox exit event I edit the query to add in a where param.
Now my issue is that when the form loads the first time it displays the information in the list box as it should. However, when it loads a subsequent time the listbox displays the information from the previous query, not the most up to date. Do I need to "repaint" or "refresh" my form somehow so that the listbox is updated to the query results that I want? If I open the query it is showing the data I want it to, just the form is not updating.
My VBA looks like this:
Now my issue is that when the form loads the first time it displays the information in the list box as it should. However, when it loads a subsequent time the listbox displays the information from the previous query, not the most up to date. Do I need to "repaint" or "refresh" my form somehow so that the listbox is updated to the query results that I want? If I open the query it is showing the data I want it to, just the form is not updating.
My VBA looks like this:
Code:
Private Sub cboOne_Exit(Cancel As Integer)
List13.ForeColor - vbBlack
Dim dry As String
Dim qdf As QueryDef
On Error Resume Next
DoCmd.DeleteObject acQuery, "ListBoxQuery"
dry = "Query SQL Here"
Set pdf = CurrentDb.CreateQueryDef("ListBoxQuery", dry)
DoCmd.OpenQuery qdf.Name
qdf.Close
Set pdf = Nothing
End Sub
Private Sub Form_Load()
List13.ForeColor = vbWhite
End Sub