form field, allow asterisk or numbers only (1 Viewer)

Cirrostratus

Registered User.
Local time
Today, 06:06
Joined
May 16, 2013
Messages
29
I've got a form where the user can only enter the character asterisk or numbers. No letters or other special characters allowed.

The asterisk is a problem since its a wildcard. How do I allow the user to use it or numbers only? I've tried Validation Rules, I've tried vba but I don't seem to manage to get this to work properly.

Any ideas?!?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:06
Joined
Feb 19, 2013
Messages
16,604
I think you need to write a function which you can then call from you validation rule

Put this in a module rather than the form vba

Code:
Public Function ChkStr(myString as String) as boolean
Dim i As Integer
 
    chkStr=true
    for i=1 to len(mystring)
        if instr("0123456789*",mid(myString,i,1))=0 then
            chkStr=False
            exit function
        end if
    next i
 
end function

then in your validation rule put

Code:
chkstr(nz([mystring]))=true
change mystring to the name of the control
 

Users who are viewing this thread

Top Bottom