Hi, I'm not 100% sure what to look for on this one, so I'm hoping for some guidance.
I have a search form that has a listbox on it, filled by a query. Currently you can double click on one of the entries, and it will open another form to view the details about the item you selected. When I'm opening the new form, I'm also using OpenArgs to pass a couple pieces of data that I need on the details form to correctly specify which exact record I want to see.
In the details form, I have two listboxes that the users can click to show different records, related to the main record. I'm passing to the form the data I would like to have selected on the listboxes when the form opens.
This is my OnLoad for the details form:
Code:
Private Sub Form_Load()
Dim varSplitString As Variant
Dim stDash As String
Dim stVariant As String
If Not IsNull(Me.OpenArgs) Then
varSplitString = Split(Me.OpenArgs, "|")
stDash = varSplitString(0)
stVariant = varSplitString(1)
End If
Looking at the debug, my data comes through fine. My stumbling block is the listboxes. They are ListDash and ListVariation, and they fill based on a query. How do I have the listboxes selected based on what stDash and stVariant are when the form opens? I've tried setting the value and some other tricks, but everything just errors out. I'm thinking I need to loop through the data in each listbox, compare it to the variables, and have it use the Selected property to choose which one matches? Or is there a simpler way of doing things?
Thanks!