How to set a default value so words can be added to the value?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to automaticly insert text into a field as a default (like a
template) but then be able to add to the text without the default text
disappearing. How can this be done. The field is open text. An example of
what I would like to do is have the words "To:" be the default but then be
able to add a name with erasing the "To:" . Thank you for the help
 
Set the Default Value property of the field to:
"To:"

Use the Enter event of the control on your form to set SelStart to the Len()
of the Text in the control.
 
While Allen's solution is certainly the easiest, you might also check out
the "XP Cue Banner" approach I described in my Feb, 2004 Access Answers
column in Pinnacle Publication's Smart Access, as well as the extension
proposed in my Oct, 2004 column.

You can download both columns (plus accompanying databases) for free at
http://www.accessmvp.com/djsteele/SmartAccess.html
 
I am a little confused on how to Enter this event. Do I need to do this in
the form prior to or when adding the field or can I modify this if the field
and text box is already in the form. Thank you for your help.
 
Open your form in design view.
Right-click the text box, and choose Properties.
On the Event tab of the Properties box, you will see On Enter.
The code will go into that event procedure.
 
Hi Allen

I face the same problem but it's been a long time since I solved it. What is
the exact syntax of the code? I've tried entering

Set SelStart=3

but it returns an error message

I've also tried

SetValue.[SelStart]=3 with the same result
 
This example could go in the Click event of a command button.
It inserts the word "To:" into the text box named "Text0", sets focus to the
text box, and then parks the cursor after the end of the text.

With Me.Text0
.Value = "To:"
.SetFocus
.SelStart = .SelLength
End With

If you wanted the cursor to always go to the end of the text for all
controls:
Tools | Options, | Keyboard | Behavior entering field
 
Hi Allen,

Is there a way to have the template of a text field be something like this?

Sender:
Title:
Phone:
Email:

Instructions:

User can then enter text in this field based on the template shown here.

Thank you.

Sincerely,

Jean-Francois Gauthier

Allen Browne said:
This example could go in the Click event of a command button.
It inserts the word "To:" into the text box named "Text0", sets focus to the
text box, and then parks the cursor after the end of the text.

With Me.Text0
.Value = "To:"
.SetFocus
.SelStart = .SelLength
End With

If you wanted the cursor to always go to the end of the text for all
controls:
Tools | Options, | Keyboard | Behavior entering field

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

paulpenta said:
I face the same problem but it's been a long time since I solved it. What
is
the exact syntax of the code? I've tried entering

Set SelStart=3

but it returns an error message

I've also tried

SetValue.[SelStart]=3 with the same result
 

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

Back
Top