Setting Default Value by using Code for unbound textbox

A

Allen Browne

You could assign a default value in the Open event of the form:

Private Sub Form_Open(Cancel As Integer)
Me.Text1.DefaultValue = """Hi Fred"""
End Sub

If the text box is intended to be a number, set its Format property to
General Number, and assign the Default Value like this:
Me.Text1.DefaultValue = "88"
 
1

1

Thank you for your help and answer:
How can I set Default Value by using code for unbound text box?
Notes
The value of the text box will be the Default Value...
 
A

Allen Browne

You will need to store the user's requested default from Text2 into a table.
Then next time the form is opened, DLookup() the value in the form's Open
event, and assign it to the DefaultValue of the text box.

For an example of how to store and retrieve the value see:
Return to the same record next time form is opened
at:
http://allenbrowne.com/ser-18.html
Although that article describes storing and retrieving for a different
purpose, the table structure and saving and retrieving can be used for
default values as well.
 
1

1

Thank you very much for your help and answer..
Can I use another textbox value to assign default value????
This what I do....
Me.Text0.DefaultValue = Chr(34) & Me.Text2.Value & Chr(34)
The only Problem is when close the form the default value is (((((DELETED OR
EARSED) form the text box
Notes:
I don't want to type the Default value by code i want the user type the by
using another text box or the value of same text box..
notes:
Form and text box unbound control..

I hope you can understand me...
 

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