I am trying to refer to a multi select listbox property on a subform from the main form. Sounds simple but I guess it is not. It is a part of long code and query in vba. The listbox will gather all the selections in the listbox to feed it into a query.
I had the listbox on a tabbed control on the main form (tabbed control) and everything was working fine but the fields were so much on the tab which makes the page too long so I decided to add those fields on a subform. But I could not refer to the listbox on the subform to gather all the selections in the listbox
When the listbox was on the main form and everything was fine, this is the code I used
When the listbox was moved to a subform and it did not work, this is the code I used
When I run the second code I get the following message:
Run-time error '438':
Object doesn't support this property or method
So I am not sure if this is doable.
Any suggestions on modifying the second code?
I had the listbox on a tabbed control on the main form (tabbed control) and everything was working fine but the fields were so much on the tab which makes the page too long so I decided to add those fields on a subform. But I could not refer to the listbox on the subform to gather all the selections in the listbox
When the listbox was on the main form and everything was fine, this is the code I used
Code:
For Each varItem In Me.[FieldName].Itemselected
strEmpl = strEmpl & ",'" & Me.[FieldName].ItemData(varItem) _
& "'"
Code:
For Each varItem In Me!Subform1.Form![FieldName].Itemselected
strEmpl = strEmpl & ",'" & Me!Subform1.Form![FieldName].ItemData(varItem) _
& "'"
Run-time error '438':
Object doesn't support this property or method
So I am not sure if this is doable.
Any suggestions on modifying the second code?