LPARAMETER ValString MyString = ValString #DEFINE Line1Message "Invalid Entry " + CHR(13) #DEFINE Line2Message "Click OK to correct Invalid Entry" ** find out to see how long the string is myLen = LEN(MYSTRING) *** Find out how many controls we have NumLoops = OCCURS(',',Mystring) + 1 FOR lnCount = 1 TO NumLoops ComPosition = AT(',',MyString) IF ComPosition = 0 ThisValidField = MyString MYSTRING = '' ELSE ThisValidField = LEFT(MyString,ComPosition - 1) myLen = LEN(MyString) MYSTRING = RIGHT(MYSTRING,MyLen - ComPosition) ENDIF ThisValidFieldValue = 'THISFORM.'+ALLTRIM( ThisValidField) + '.VALUE' IF EMPTY(&ThisValidFieldValue) MESSAGEBOX(Line1Message+Line2Message,64,'Error') ThisValidSetFocus = 'THISFORM.' + ALLTRIM( ThisValidField) + '.SETFOCUS()' &ThisValidSetFocus RETURN .F. ENDIF ENDFORThis of Course is very generic. If you wanted to be mor specific you could try this:
*** Method m_ValidateSpecificField lparameters tcControlName,tcWeWillCallItThis IF PCOUNT() < 1 Return ELSE do case case tcControlName = 'SomeControlOnTheForm' *** do some specific Stuff *** Send a message back using name contained in tcWeWillCallItThis *** set the focus back to that control (SomeControlOnTheForm) case tcControlName = 'AnotherControlOnTheForm' *** do some specific Stuff *** Send a message back using name contained in tcWeWillCallItThis *** set the focus back to that control (SomeControlOnTheForm) && Do this until all of your specific Code is accounted for endcase ENDIFIf you put your Validation in a method or a Com object it is Much easer to maintain if you should decide to change something down the road.