By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Where to put code for form control properties

P: n/a
I am trying to set a combo box to list the fields in one of my tables.
I am using the code

Dim MyControl As Control
Set MyControl = Forms![Form1]![Combo2]

MyControl.RowSourceType = "Field List"
MyControl.RowSource = "tlbMedications"
MyControl.Value = MyControl.ItemData(0)

The problem I (a pure novice) am having is that I can't figure out
where to stick the procedure in which the code would reside. Should it
be tied to an event on the form, or a standard procedure, or what???

Jul 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ch***************@charter.net wrote:
I am trying to set a combo box to list the fields in one of my tables.
I am using the code

Dim MyControl As Control
Set MyControl = Forms![Form1]![Combo2]

MyControl.RowSourceType = "Field List"
MyControl.RowSource = "tlbMedications"
MyControl.Value = MyControl.ItemData(0)

The problem I (a pure novice) am having is that I can't figure out
where to stick the procedure in which the code would reside. Should
it be tied to an event on the form, or a standard procedure, or
what???
Why are you setting it with code? Is it sometimes displaying a different
RowSource? If the RowSource is dynamic then what EVENT triggers the change?
Once per form instance? Once per record? The former would make the Open or
Load event of the form the appropriate place to run the code. The latter would
make the form's Current event the most appropriate place. You need to provide
more details about your needs and expectations.

If the list is not dynamic then you shouldn't use code at all, but just set the
properties for the list in form design view and be done with it.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jul 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.