default value

maxmangion

AWF VIP
Local time
Today, 20:54
Joined
Feb 26, 2003
Messages
2,805
i have an unbound text box in a form, and i would like that when a user selects a value from this combo box he clicks a button and that value would become the default value for a particular field in a table.

Is this possible ?

Thx!
 
default values

If you'll be using a form to input data into the table then it's not too hard to do this.

Suppose data will be entered in a subform of a main form that will be open when your user is filling in the text box that sets the default.

This code should do what you want:

Code:
Forms("Main_Form")("Sub_Form").Form.Controls("Control_Name").DefaultValue = Me.txtDefault

You'l need to edit this code, though, replacing:

Main_Form with the name of your main form (but leave the quotes in place),

Sub_form with the name of the box thing on the main_form in which the sub_form shows up (leave the quotes in place), and,

Control_Name with the name of the control in which data with the new default will be entered.

If you're not using a subform, it's easier:

Code:
Forms("Main_Form").Controls("Control_Name").DefaultValue = Me.txtDefault

You could also try this by getting hold of the table definition in code and then changing the default values for various fields. This is a bit harder to do, though, and won't work if data in the table is already being looked at by a form, by another access object, or by another user.
 

Users who are viewing this thread

Back
Top Bottom