473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Where to put code for form control properties

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
1 1377
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mb | last post by:
I have a button on a form, but when I look at the button properties window it only has a few properties. How do I get the rest in the window, like BackColor, for instance? I would like it if I...
3
by: Roberto Castro | last post by:
Hello! I have been assigned for the first time an adp Access project and so far I have managed to make the changes needed for some requirements. However, I am struggling to find the place where...
4
by: Soryt | last post by:
Hi everyone ! 1) An example from help: "Each Form object has a Controls collection, which contains all controls on the form. You can refer to a control on a form either by implicitly or...
10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
11
by: Tim Marshall | last post by:
I use Terry Kreft's & Stephen Lebans colour dialog procedures for users to pick colours for various control properties in certain apps. Is there a way to take the colour code that is displayed in...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
3
by: teo | last post by:
When I Cut and Paste controls (ie: from a 'Form' to a 'Tab control' that I just put on the Form) the pasted controls regularly arrive with their properties, but the code behind them remains...
8
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.