forms - Check if field contains any numbers? -


hi i'm trying write vba checks whether 1 of text boxes contains number. text box called: customername. here's code using:

function hasnumber(strdata string) boolean     dim icnt integer      icnt = 1 len(strdata)         if isnumeric(mid(strdata, icnt, 1))             hasnumber = true             exit function         end if     next icnt  end function  private sub customername_afterupdate() if hasnumber(customername)     msgbox "only letters allowed field."     exit sub end if  end sub 

for reason when enter numbers field , click out of (i.e. update it) doesn't come msgbox or anything. can fix this?

instead of using custom code, use validation rule on customername column of table, or on validation rule of text box:

not "*[0-9]*" 

see here reference of validation rules.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -