Microsoft Access Office VB VBA Help and Examples
           
             

Easy Inserting Special Characters in Data Entry Forms

If you have a form which users need to insert foreign characters or scientific symbols on and don't want to teach them all the special char codes for those characters then this piece of code shows you how to get a combo box with those characters in that will append  the character to the last field the user was in.

Take the form where you want this special feature. Add a combo box and call it PickSymbol. For its change event enter the following code.

Private Sub PickSymbol_Change()
    On Error GoTo ErrorHandler
    Dim ctl As Control
    Dim txt As String
    Set ctl = Screen.PreviousControl
    txt = ctl.Value
    txt = txt & PickSymbol.Text
    ctl.Value = txt

ResumeHandler:
    ctl.SetFocus
    sendkeys("{F2}")
    Set ctl = Nothing
    Exit Sub

ErrorHandler:
    MsgBox "The previous field " & ctl.Name & " cannot have " _
       & "another character appended to it?", vbOKOnly
    GoTo ResumeHandler
End Sub

Set the row source type to value list and the row source to "";"";"" or whatever characters you want to include from the character map utility.

When you run the form, type in a field and then choose a symbol from the combo box which will then be inserted at the end of whatever you typed and the focus set back to that control.

 
HOME   SEARCH SITE   PRIVACY POLICY   CONTACT
The code and application content of this site is copyright of Smiley I.T. and as such reproduction in any form which is for commercial use requires the permission of the Webmaster. Any use of this code for non-commercial use only requires a link or comment back to the original page you took the code from.