Airfield Models - Visual Basic Database

Converting VB DB to a Daily Quote Applet (Developer's Version) - Step 7

May 05, 2015



Home
About
Site Feedback
Register
Contact
Site Map
Add to Favorites
Tell a Friend
Comments
Items For Sale
Search Airfield Models

Back to VB DB

 

Airfield Models (http://www.airfieldmodels.com/)Converting VB DB to a Daily Quote Applet
(Developer's Version)

Download VB DB Source Code here.

 
 

Step 7 of 7

Now it is time to add validation code.  In order for the validation to prevent the data from being saved, an error must be raised to let the calling function know that the data can't be saved.

Validation code

Ultimately, validation is handled by the cTable.cls class module.  However, the class simply validates that the data entered in a field is of the type defined for the field.  You must add your own validation code if you want to check that certain entries fall within a range of values.

In this example we do not want to let the user save the data unless there is text in both the Quote field and the Author field.

We previously set the Required property of each field to True so this code is not necessary.  However, this is the best place to validate user input before saving the record.

' frmDatabase.frm

Private Function Validate() As Long

On Error GoTo errHandler

If (Trim$(txtQuote.Text) = vbNullString) Or (Trim$(txtAuthor.Text) = vbNullString) Then
 
Err.Raise APPLICATION_ERROR.ERR_REQUIRED_DATA_NOT_ENTERED
End If

Exit Function

errHandler:
Validate = Err

End Function

 
 

Previous
Next

Step 6 of Converting VB DB to a Daily Quote Applet (Developer's Version)
Final Step to Converting VB DB to a Daily Quote Applet (Developer's Version)

Comments about VBDB

 
 

Back to VB DB
Airfield Models Home

 
 

Copyright 2002-2005 Paul K. Johnson