473,803 Members | 3,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5331
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.spea keasy.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****@somewher e.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****@somewher e.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
4285
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
10067
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 form(s) for the table(s) in question. The "United States" Country name & the "US" Country code are selected 99% of the time. I would like to have the "United States" & "US" be the default values
2
24892
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 the default I am settign will be one of the values from teh drop down list.. How do you set a default value for a combo box?? Thanks, Brad
2
6528
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 combo boxes to default to a selection that is either blank or the column head, so that my users don't see their previous selection when they go and select a value from the drop down list. Also, what would be the best way to enable a user to clear out...
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9565
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.