View Single Post
 
Old 03-22-2019, 04:48 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

There is no point having a separate validation macro if you are going to put all 8 cases there. You want the validate macro to be passed some variables so you can merge the processing

Code:
Private Sub txt1_AfterUpdate()
    Validate (Me.txt1, "Number")
End Sub

Sub Validate(aCtrl as control, sValidate as string)
  Select Case sValidate
    Case "Number"
      If Not IsNumeric(aCtrl.Text) Then
        MsgBox ("Must be a Number")
        aCtrl.SetFocus
      Else
        aCtrl.BackColor = vbWhite
      End If
    Case "Text"
    
  End Select
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote