Fairly simple question. I have a text field in a form that I would like the default value to be set to the result of a query. This particular query returns a default tax rate for a small invoicing system I am setting up in Access.
The query (qrySettingsDefaultTaxRate) looks like this and returns one row with the decimal equivalent of the tax rate I would like to set as the default in this form:
SELECT CDbl([value]) AS default_tax_rate
FROM settings
WHERE (((settings.key_name)="default_tax_rate"));
I have tried setting the default value of my text field to:
=[qrySettingsDefaultTaxRate]![default_tax_rate]
However that didn't work. When I return to form view, the box comes up with "#Name?" as the default value instead of returning the result of the query.
Default value is 0. Placeholder text is a short description or hint that that describes the expected value of an input field. (For example, "Enter phone number xxx-xxx-xxxx"). The short hint is displayed in the input field before the user enters a value.
The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now() , the control displays the current date and time.
You can set the control source of a textbox to DLookup, or set the value to DLookup in code.
DlookUp("default_tax_rate","qrySettingsDefaultTaxRate")
Or
DlookUp("default_tax_rate","settings","settings.key_name='default_tax_rate'")
You can even put DLookUp on the property sheet under Default Value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With