Recognising the data type

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

Guest

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
 
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
 

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