473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting default value

418 Contributor
My combo box is pulling data from tblAccounts using its PK (auto number) AccountID but displaying AccountNo (text).

Is it possible to set the default value for this combo box to one of the AccountNos?

Let me explain
AccountID = 1
AccountNo = 4xxxx

I would like cboAccount which is a combo box on a subform (sfrmGrantBudget) to display "xxxxx" as a default value. Is it possible? When I tried, it displays the AccountID for AccountNo XXXXX

tblGrantBudget is related to tblAccounts with a join type of 1.

Thanks.
Apr 30 '09 #1
5 2205
ChipR
1,287 Recognized Expert Top Contributor
M,
I had no problem setting a default for a combo box in a quick test. Is your combo box bound to column 1 (accountID) and displaying 2 columns, with the first 0"? Did you attempt to set the default value on the Data tab of the combo box properties to an account ID?
Apr 30 '09 #2
MNNovice
418 Contributor
Answer to all your questions are YES.

On the Data tab: I have
Bound Column = 1
Control Source = AccountID
Row Source = SELECT tblAccounts.AccountID, tblAccounts.AcctNo, tblAccounts.AcctDescr FROM tblAccounts;

Format Tab:
Column Count = 2
Column Widths = 0"; 1";

I guess I must not be doing something right somewhere.
Apr 30 '09 #3
DonRayner
489 Recognized Expert Contributor
You need to set the "Column Count" property for the combo box to 2. Then if you only want it to display the AccountNo but not the AccountID you would set the "Column Widths" property to something like 0";2" thus hiding the first column containing the AccountID

What you end up with is a combo box that displays the AccountNo but is bound to the AccountID.
Apr 30 '09 #4
MNNovice
418 Contributor
DonRayner:

I have no problem with displaying the data as you described. However, my problem lies when I select a default value to read, for example,
AccountNo as "4XXXX" it displays AccountID 91.

Thanks.
Apr 30 '09 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. You are confusing the value of the account number displayed - the 4XXXXX bit - with the value of the bound column.

The default value in the case of a combo box applies to the bound column, regardless of which columns are visible and which are hidden.

As the controlsource of the combo is AccountID, presumably a long-integer number generated by an autonumber field in the related table, the bound value should also be a long-integer number.

In the example you give, the 4XXXXX bit corresponds to an AccountID of 1, so 1 should be your default value for the combo if that is the value you want to display. If the default value you want is a different account number, you will need to supply the actual ID number for that value (e.g. 91, say, or whatever other long-int ID value matches the account number concerned). You will see all of this more clearly if you do not set columns to hidden to begin with.

-Stewart
Apr 30 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: the.theorist | last post by:
I have a small, simple class which contains a dictionary (and some other stuff, not shown). I then have a container class (Big) that holds some instances of the simple class. When I try to edit the...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
3
by: Barbara Lindsey | last post by:
I have a case where I am collecting a "Start Date" and an "End Date". I would like to default the "End Date" to the "Start Date" value if only the "Start Date" is entered. I tried setting this as...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
10
by: Brad Baker | last post by:
I have an asp.net/csharp application that requires a particular variable to work properly. This variable is usually passed via a query string in the URL when the application is first run but under...
8
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list...
7
by: PetterL | last post by:
I have a setting called My.settings.firstrun set to True, set in the setting manager. When i read this in the first form form_Load in a IF sentence it always come out as false. I have tried to...
1
by: RobertTheProgrammer | last post by:
Hi all, I have a perplexing problem here. I've developed some software using ASP.NET with C# in the code behind. I've been setting the "window.defaultStatus" in the code behind to send messages...
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
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
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,...
1
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
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,...
1
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...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.