Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use a dialog box to throw errors?

Status
Not open for further replies.

rundmc

Programmer
Jan 16, 2003
15
US
Can anyone tell me how to use a dialog to box to inform the user that they have left required fields unpopulated?

Thanks

rundmc
 
Do u want to show error messages from the datasource or u want to validate fields on the form before performing data manipulation??? In case you want second scenario u can do as follows

Private Function ValidateFields() As Boolean

If Trim(TextBox1.Text) = "" Then
MessageBox.Show("Your message here")
TextBox1.Focus()
Exit Function
ElseIf Trim(TextBox2.Text) = "" Then
MessageBox.Show("Your message here"
TextBox2.Focus()
Exit Function
End If

Return True

End Function

Then let's say on Click of Save Button, call this function before performing data manipulation

If ValidateFields = True Then
'Perform Insert
End If


Otherwise you’ll have to use structured error handling Try...Catch...End Try block

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top