VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Check that you have completed all fields on the form with numeric checks and empty checks.

by Muhammad Rafique (4 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 15th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Check that you have completed all fields on the form with numeric checks and empty checks.

API Declarations


'and n for numeric field
' call it in the update procedure
' if function returns True then update else
' it automatically select the faulty field

Rate Check that you have completed all fields on the form with numeric checks and empty checks.



  dim ctl as Control
 For Each ctl in Controls
   If TypeOf ctl is TextBox then
    Select Case ctl.Tag
       Case "r"
         If Len(Trim(Ctl.Text))=0 then 
           MsgBox ctl.DataField & " Can not be empty Click OK to Have Focused it."
           ctl.SetFocus
           SenKeys "^{HOME}+^{END}",True
           Exit Function
         End If
       Case "n"
         If Not IsNumeric(ctl.Text) then 
           MsgBox ctl.DataField & " Can not be Non Numeric Click OK to Have Focused it."
           ctl.SetFocus
           SenKeys "^{HOME}+^{END}",True
           Exit Function
         End If
       Case "+"
         If Not (IsNumeric(Ctl.Text) AND Val(ctl.Text)>0) then 
           MsgBox ctl.DataField & " Must be Numeric and Positive, Click OK to Have Focused it."
           ctl.SetFocus
           SenKeys "^{HOME}+^{END}",True
           Exit Function
         End If

    End Select

   End If
 Next
ValidationIsOk=True
End Function

'Call it like 
Sub cmdUpdate_Click()
  'e.g
  If ValidationIsOk then 
     'Update my record
  Else
     'Problem statement is automatically from 'ValidationIsOk Function'
  End if
End Sub

Download this snippet    Add to My Saved Code

Check that you have completed all fields on the form with numeric checks and empty checks. Comments

No comments have been posted about Check that you have completed all fields on the form with numeric checks and empty checks.. Why not be the first to post a comment about Check that you have completed all fields on the form with numeric checks and empty checks..

Post your comment

Subject:
Message:
0/1000 characters