Recognising the data type

B

bvdahl

Hello,

I have a field, that I want to use as both a search field and an entry for a
customer number. What I need, is to write a code that kicks in when the first
character is written in the form (Change event, I would think) and that
checks if that character is a number or a letter.

The code would then go something like this

if firstcharacter is number then

let user continue writing

else

go to search screen to look up customer number

what would that code look like?

Baard
 
B

Bob Hairgrove

Hello,

I have a field, that I want to use as both a search field and an entry for a
customer number. What I need, is to write a code that kicks in when the first
character is written in the form (Change event, I would think) and that
checks if that character is a number or a letter.

The code would then go something like this

if firstcharacter is number then

let user continue writing

else

go to search screen to look up customer number

what would that code look like?

Baard

You can use a simple comparison, e.g.:

Dim key As String
If Len(MyControl.Text) = 1 Then
key = Left(MyControl.Text, 1)
If key >= "A" And key <= "Z" Then
' open the search screen
End If
End If
 
Top