To generate reusable code
-
I am retrieving a field from the database into a combobox.I have to retrieve the same data into the combobox in 3 different forms.How can i simplify this.Do i write a common procedure?
-
I am retrieving a field from the database into a combobox.I have to retrieve the same data into the combobox in 3 different forms.How can i simplify this.Do i write a common procedure?
This all depends on how your Forms are related. Sometimes, if one Form is an Extension of another, simply use "Visual" Inheritance. Typically, I write individual Sub Routines for each ComboBox (as opposed to one Massive Routine that Refreshes all Data in every control...blech!). If this is your case, and it seems you are using this in more than one Form, place your Routine in a Module and Pass the ComboBox as a Parameter so it can fill the correct one.
'In Module...
Public Sub RefreshCityList(ByRef CboList As ComboBox)
'Place Logic Here...
End Sub