Still module problem (1 Viewer)

faizulhu

Registered User.
Local time
Today, 09:27
Joined
Oct 30, 2006
Messages
15
I am a novice user and so please elaborate the solution of my problem. I need the entire code.

I created a module based on the instruction on Microsoft's Knowledge Base(KB210385) to create a validation rule to accept only alphabetical characters. The code of the module is given below:

Option Compare Database

Option Explicit
Function IsAlpha(MyString As String) As Integer
Dim LoopVar As Integer
Dim SingleChar As String

LoopVar = 1

If IsNull(MyString) Then
IsAlpha = False
Exit Function
End If

For LoopVar = 1 To Len(MyString)
SingleChar = UCase(Mid$(MyString, LoopVar, 1))
If SingleChar < "A" Or SingleChar > "Z" Then

IsAlpha = False
Exit Function
End If
Next LoopVar

IsAlpha = True

End Function

The module works on my fields but it does not allow any spaces or gaps in the fields which makes it almost useless for my database. So can anyone help me to resolve my problem by giving me the code of the module which will accept alphabets and spaces but not numbers or punctuation marks.
 

raskew

AWF VIP
Local time
Yesterday, 21:27
Joined
Jun 2, 2001
Messages
2,734
Hi -

Modify this one line and it should work for you:

Use this line:
Code:
    If Asc(SingleChar) <> 32 And Asc(SingleChar) < 65 Or Asc(SingleChar) > 90 Then

Chr(32) = space

HTH - Bob
 
Last edited:

faizulhu

Registered User.
Local time
Today, 09:27
Joined
Oct 30, 2006
Messages
15
Thanks a lot raskew. That really works!
 

Users who are viewing this thread

Top Bottom