Gimpster
Nov 3rd, 1999, 05:09 AM
Ok, what I'm trying to do, is create an error handling routine. What I want the program to do, is check to see if any of four text boxes are empty, and if one is, then it displays the appropriate error message. Then once it is done, IF AND ONLY IF it had found any errors, then I want it to end the sub. However, I do not know how to code this. I have included the code that I have tried already, but this gives me an error message on the "End Sub" line in the If Then statement, whether the statement is true or not. Please help me figure out how I can do this. (The dsnerror, uiderror, and pwderror, are other commands run from a module)
Private Sub cmdContinue_Click()
dbname = txtdbname.Text
dsn = txtdsn.Text
uid = txtuid.Text
pwd = txtpwd.Text
If txtdbname.Text = "" Then
MsgBox ("Please enter a name for the database you wish to connect to."), , "Error: database name not entered"
dsnerror
uiderror
pwderror
End Sub
End If
If txtdsn.Text = "" Then
MsgBox ("Please enter a data source name for the database you wish to connect to."), , "Error: dsn not entered"
uiderror
pwderror
End Sub
End If
If txtuid.Text = "" Then
MsgBox ("Please enter a valid username for the database you wish to connect to."), , "Error: No username entered"
pwderror
End Sub
End If
If txtpwd.Text = "" Then
MsgBox ("Please enter a valid password for the database you wish to connect to."), , "Error: No password entered"
End Sub
End If
On Error GoTo dberror
X = "ODBC;database=" & dbname & ";DSN=" & dsn & ";UID=" & uid & ";PWD=" & pwd
Set db = OpenDatabase("", False, False, X)
dberror
MsgBox ("Some of the information you entered was invalid, please re-enter the information and make sure that it is correct."), , "Error: Invalid Information Entered"
End Sub
Load frmMain
frmStartup.Hide
frmMain.Show
Unload frmStartup
End Sub
------------------
Thanks,
Ryan
corneslen@hotmail.com
ICQ# 47799046
Private Sub cmdContinue_Click()
dbname = txtdbname.Text
dsn = txtdsn.Text
uid = txtuid.Text
pwd = txtpwd.Text
If txtdbname.Text = "" Then
MsgBox ("Please enter a name for the database you wish to connect to."), , "Error: database name not entered"
dsnerror
uiderror
pwderror
End Sub
End If
If txtdsn.Text = "" Then
MsgBox ("Please enter a data source name for the database you wish to connect to."), , "Error: dsn not entered"
uiderror
pwderror
End Sub
End If
If txtuid.Text = "" Then
MsgBox ("Please enter a valid username for the database you wish to connect to."), , "Error: No username entered"
pwderror
End Sub
End If
If txtpwd.Text = "" Then
MsgBox ("Please enter a valid password for the database you wish to connect to."), , "Error: No password entered"
End Sub
End If
On Error GoTo dberror
X = "ODBC;database=" & dbname & ";DSN=" & dsn & ";UID=" & uid & ";PWD=" & pwd
Set db = OpenDatabase("", False, False, X)
dberror
MsgBox ("Some of the information you entered was invalid, please re-enter the information and make sure that it is correct."), , "Error: Invalid Information Entered"
End Sub
Load frmMain
frmStartup.Hide
frmMain.Show
Unload frmStartup
End Sub
------------------
Thanks,
Ryan
corneslen@hotmail.com
ICQ# 47799046