Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Create an Auto Text function for Access

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hi

I am using Access 2003 and I'm wondering what I can do to create an autotext type function. For instance, the user wants to be able to type in E11, for instance, which would copy text into a memo/text box and that they could then add further comments to the memo/text box.

Is this possible with macros? Other thoughts? Thanks.
 
In the Access Options, you can set AutoCorrect options to replace some code or whatever with something else. I would make sure I choose rather obscure codes to replace.

Duane
Hook'D on Access
MS Access MVP
 
You may find this idea of use ... I created a table containing two fields:

AutoTextID - text field, 2 chars, primary key
AutoText - text field, 50 chars

I wrote some test records into this table, e.g.

A1 - This is test paragraph A1
B2 - This is test paragraph B2

Assume I have a text field in my main data table, linked to a field on a form. In my demo I called this AutoTextDemo. This is the field in which I'd like to type either an AutoText code - to be replaced by text - or any other text, which is just stored.

In the On Lost Focus event of the form field I put this code:

Code:
Private Sub AutoTextDemo_LostFocus()

If Len(AutoTextDemo.Text) = 2 Then
    AutoTextDemo.Text = DLookup("[AutoText]", "tblAutoText", "[AutoTextID]='" & AutoTextDemo.Text & "'")
End If

End Sub

The result is:
-- If I type a code such as A1 into the form field, when I tab out of the field it's replaced by the text looked up from the AutoText table
-- If I type anything else in the field, it is just stored unchanged

You would set the length of the AutoText field in the lookup table to be suitable for your longest piece of auto text.

I hope this is useful to you.



Bob Stubbs (London, UK)
 
Hi Bob

Thanks for replying. In your scenario, however, the user wouldn't be able to add to the AutoText.

For instance, if I had A1 be "Incorrect code selection for" then I would want the user to finish the statement "diabetes". It would be far too huge to have a sentence entry for each possible scenario but to cut down on key strokes I wanted to give them a "starter" and to also then be able to take what is collected to put into a Word document.

Thanks.
 
Shelby55,
Would a solution that allows a user to type in something like "~" into a text box and have a dialog form open with a combo box to select a phrase for insertion work?



Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top