473,385 Members | 1,620 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,385 software developers and data experts.

Default Value in Drop Down Combo Box

I have a number of Drop Down Combo Boxes where users select a country;
99% of the time the selection will be "United States".

I want to use VBA code in the New Record Event to populate this field
with "United States" as the default value, but still allow the users to
select another value (country) on those rare occasions where it applies.

I just want to make sure that this code will not cause any conflicts
with the normal functionality of the Combo Box.
Nov 12 '05 #1
3 5283
The combobox has a property called Default Value. Why not set it there
instead of using code?

Mike Storr
www.veraccess.com
"Todd D. Levy" <us**************@spamex.com> wrote in message
news:MP************************@nyc.news.speakeasy .net...
I have a number of Drop Down Combo Boxes where users select a country;
99% of the time the selection will be "United States".

I want to use VBA code in the New Record Event to populate this field
with "United States" as the default value, but still allow the users to
select another value (country) on those rare occasions where it applies.

I just want to make sure that this code will not cause any conflicts
with the normal functionality of the Combo Box.

Nov 12 '05 #2
Mike,

The reason I don't use this method is that it apparently only works when
the form (that the combo box in question in on) is opened directly.

If it is opened (for instance) via a VBA coded button on another form
the default value is not picked up.

I have tried setting the default value in properties at the form level
as well as for the field at the table level without success.

Unfortunately the code I am using is not working properly either:

In the On Current event I have the following

If Me.NewRecord Then
Me.ComboBox = "XYZ"
End If

What am I doing wrong?

Todd D. Levy

In article <s_*******************@news20.bellglobal.com>,
no****@somewhere.con says...

The combobox has a property called Default Value. Why not set it there
instead of using code?

Mike Storr
www.veraccess.com


Nov 12 '05 #3
On Sat, 31 Jan 2004 14:07:13 -0500, Todd D. Levy wrote:
Mike,

The reason I don't use this method is that it apparently only works when
the form (that the combo box in question in on) is opened directly.

If it is opened (for instance) via a VBA coded button on another form
the default value is not picked up.

I have tried setting the default value in properties at the form level
as well as for the field at the table level without success.

Unfortunately the code I am using is not working properly either:

In the On Current event I have the following

If Me.NewRecord Then
Me.ComboBox = "XYZ"
End If

What am I doing wrong?

Todd D. Levy

In article <s_*******************@news20.bellglobal.com>,
no****@somewhere.con says...


ComboBox is a reserved word, so if that is the name of your control in
question, you may experience a number of problems. If it is, change it's
name and try again, if it's not and you are using the proper control name,
then I'm not sure what's going on. The Default Value property and your code
should accomplish the same thing. Except that using your code, if the focus
leaves your form and comes back, the combobox value may change when you
don't want it to.

--
Mike Storr
veraccess.com
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: akl | last post by:
How can I create such a default value that it depends on the value in other field (drop down)? So that the default value would be updated every time I change the value of drop-down field.
2
by: Todd D. Levy | last post by:
I have a table of Country names & Country codes in alphabetical order. This is a lookup table that a number of other tables use to populate the Country field via a drop down Combo Box on the...
2
by: Brad Pears | last post by:
In my vb.net 2005 project I have a few combo boxes where I want to set a default value. I am not binding these combo boxes - I am loading the values directly in code from a dataset. Obviously...
2
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.