Setting default value property in form

D

DanJ

I want to set the Default value property of a control on an unbound dialog
form when the user checks a checkbox on the form. The dialog form has 2
unbound text box controls and a 'continue' button. The user can enter values
in the text box controls or leave the default values that appear when the
form opens. If the user checks a check box, I would like to change the
Default values of the text box controls to whatever the user entered so that
the next time the dialog form opens the new default values are entered 'by
default'.

In the cmdPrint.Click event of the form I have the following:
.. . .
If Me.Check8 = True Then
Me.txtHorzCnt.DefaultValue = Me.txtHorzCnt.Value
Me.txtVertCnt.DefaultValue = Me.txtVertCnt.Value
End If


DoCmd.Close acForm, Me.Name, acSaveYes
.. . .

For some reason, when the form closes, it is not saving the new default
values.
 
T

Tom Wickerath

Hi Dan,
For some reason, when the form closes, it is not saving the new default
values.

That's because it is unbound.
You need to run an update query in code to update the table with the user's
choice. In addition, you need to use code in the Form_Open event to read the
value from your table, and set the control appropriately. I have an example
that you can look at, if you'd like to see how this works:

http://www.seattleaccess.org/downloads.htm
See this download: Compilation of Tools by Tom Wickerath, October 2006

In leiu of this, create a bound form instead, that is bound to the table you
use to store the user selections.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top