Data Validation for form

E

Ebeneezer

In an Access 2000 DNA database I need a Validation Rule so
that only the letters A,C,G and T are accepted not only as
ACGT but in any combination and up to say 10 sequences (40
letters) e.g - CGATGTACCAGT etc etc. Can someone please
help with some VB code to do this ?
 
S

SteveS

It's hard to get work done when you are in an endless
loop. Try replacing the current code in the KeyPress event
with this: (watch for line wrap)


' check to see if lower case letters / range 97 (a) to
122 (z)
If KeyAscii > 96 And KeyAscii < 123 Then
'convert to uppercase ; subtract 32 to get
uppercase
KeyAscii = KeyAscii - 32
End If

' check for backspace - might want to correct typo
' ascii 8 is backspace
If KeyAscii = 8 Then
' move cursor left 1 char
SendKeys "{Left 1}"
' now delete it
SendKeys "{del}"
Else
If KeyAscii <> 65 And KeyAscii <> 71 And KeyAscii
<> 67 And KeyAscii <> 84 Then
' announce error
MsgBox "Invalid Entry. Must be A, C, G or T"
' move cursor left 1 char
SendKeys "{Left 1}"
' now delete it
SendKeys "{del}"
End If
End If



HTH

Steve
 

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

Top