Default value for combo box

  • Thread starter Thread starter James Agostinho
  • Start date Start date
J

James Agostinho

Hello NG,
Can some one please help me with a persistent combo box problem?

I have a form with a combo box on it that is populated by a query.

The qryTaxRate is run against tblTaxRate, and the table only has one column
TaxRate.

The TaxRate column only has 0.0%, 0.07%, 0.0725%, 0.075% and 0.0775% and is
formatted as percent, with 4 decimal places

I would like to set the default value at 0.0725%, the current sales tax in
CA, but every time I do, all I get is 0.0000%.
I've tried using the properties page for the combo box of the form and the
properties page of the table and even tried setting the default value in VBA
in the form.activate and I still only get 0.0000%.

Can someone please help me, it's driving me nuts ;-)

TIA
Jim
 
Using the Default Value should put the desired value in the combo box when
the form is opened, but unless the combo box is bound to a field in the
form's recordset and you create a new record, it won't work for subsequent
records.

When (on what event) do you want the combo box to get this default value?
Likely it will work better if we set the initial value using VBA code or
macro when that event happens (such as moving to a new record, or moving to
a different record, or opening the form, or saving the record, or
something).

Post the combo box's row source query's SQL statement as well so we can see
what it is.
 
Here is the SQL statement of the query

SELECT tblTaxRate.TaxAmount
FROM tblTaxRate
ORDER BY tblTaxRate.TaxAmount;

I would like the default to be set for a new record, also how can I get the
form to open to a new record?
Thanks for your help
Jim
 
To set the default for a new record, just type the desired value to be used
as the default into the Default Value box in the Properties dialog box while
the form is in design view.

To make the form open to a new record, in the Properties window, select Data
tab, and set the Data Entry property to Yes.
 
If you want the third choice as the Default Value .. then use this in
the Default Value property of the combobox ...

=[YourComboName].[ItemData](2)

This will have the third choice as the default selected entry.
The ItemData Index is 0 (zero) based .. so the third Item is
[ItemData](2).

HTH
RDH
 
Thanks to both of you.
The tips helped me get this problem corrected.
The tip about the ItemData helped in another problem I was having.
Thanks again.
Jim

R. Hicks said:
If you want the third choice as the Default Value .. then use this in
the Default Value property of the combobox ...

=[YourComboName].[ItemData](2)

This will have the third choice as the default selected entry.
The ItemData Index is 0 (zero) based .. so the third Item is
[ItemData](2).

HTH
RDH
 
Back
Top