Oracle Objects for OLE
Release 9.2

Part Number A95895-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

DoValidationChecks() Function

The function DoValidationChecks() returns True if the entered data is valid; otherwise it returns False.

Function DoValidationChecks() As Boolean

Dim DupDyn As Object

Dim DupDynQry As String

On Error GoTo err_ValidationCheck

ErrMsg = ""

'Empno cannot be changed while in Update mode, so we can skip over validation

If DoAdd Then

If txtEmpno = "" Then

ErrMsg = "You must enter a value for Employee Number"

Error 1

End If

End If

If txtHireDate <> "" And Not IsDate(txtHireDate) Then

ErrMsg = "Enter date as dd-mmm-yy."

Error 2

End If

If txtDeptno = "" Then

ErrMsg = "You must enter a value for Department Number"

Error 3

End If

'If adding a record, check for Duplicate empno value by

'attempting to count rows with same value

'Build Query:

If DoAdd Then

DupDynQry = "select count(*) from emp where empno = " & txtEmpno

Set DupDyn = OraDatabase.CreateDynaset(DupDynQry, ORADYN_NOCACHE)

If DupDyn.Fields(0).Value <> 0 Then

ErrNum = DUPLICATE_KEY

ErrMsg = "Employee Number already exists."

Error ErrNum

End If

End If

'Succesful validation with no errors returns True

DoValidationChecks = True

Exit Function

err_ValidationCheck:

If ErrMsg <> "" Then

MsgBox ErrMsg

Else

MsgBox Error$

End If

'Validation returns false on failure

DoValidationChecks = False

End Function


 
Oracle
Copyright © 1994, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback