Curious about listboxes

rikklaney1

Registered User.
Local time
Yesterday, 22:15
Joined
Nov 20, 2014
Messages
157
I'm curious, if I have a subform with a listbox that looks up a value. So in the listbox the criteria for that field is [mainform]![subform]![control]. But what is the best way to make that subform usable on another form? It's easy enough to just make a copy of the subform and set the listbox criteria to [mainform2]![subform2]![control] but is that really the best way? Any thoughts?
 
[Forms]![mainform]![subform]![control] is what I'm using.
 
Yep, that's how I do it now. I was just wondering if I could make one subform that could be on many different mainforms without having to change the rowsource of the listbox to reflect the different mainform. I could make a copy of the subform specifically for each mainform, or I could change the rowsource with VBA from the mainforms, but I was wondering if there was another way to call things out in the criteria. From looking at that page VBA is still the best way to go.
 
Is the ListBox on the actual SubForm and is the Control you are referencing also on that same SubForm?
 
In that case you can just use the Me.ControlName syntax and it should work for any MainForm. What sets the value in the ControlName? Is it the Record Source of this form? If so, there is absolutely NO problem.
 
Huh, I guess it just never occurred to me to try the me. anywhere other than in the vba. I'll give that a shot. Thanks.
 

Users who are viewing this thread

Back
Top Bottom