S
starlight
Guest
Hi all
I need some help. I'm trying to set up my own table for security and am then using a form to control access.
The form has 2 unbound fields for the username and password and then an enter button. On the 'OnClick' event of this button i've put in the following code (found it on this site somewhere!!);
Private Sub Enter_Click()
Dim db As Database
Dim rs As Recordset
Dim strSQL
strSQL = "SELECT * FROM tblUsers WHERE Username= '" & Me.txtUserName & "'"
strSQL = strSQL & " AND Password= '" & Me.txtPassword & "'"
Set db = CurrentDb
Set rs = db.openrecordset(strSQL)
If rs.BOF Then
'no record found
MsgBox "Incorrect!"
DoCmd.Close acForm, "frmLogins"
'quit access? DoCmd.Quit
Else
MsgBox "Welcome"
DoCmd.Open acForm, "FrmMainMenu"
DoCmd.Close acForm, "frmMain"
End If
Set rs = Nothing
Set db = Nothing
End Sub
When I enter the user name and password on the screen and click on the 'Enter' button I get the following error message;
'Error - User Defined type not defined'
I'm new to the coding part so I have no idea what this means. Can someone please enlighten me...
-----------------------------------------------------------------
St*rlight

I need some help. I'm trying to set up my own table for security and am then using a form to control access.
The form has 2 unbound fields for the username and password and then an enter button. On the 'OnClick' event of this button i've put in the following code (found it on this site somewhere!!);
Private Sub Enter_Click()
Dim db As Database
Dim rs As Recordset
Dim strSQL
strSQL = "SELECT * FROM tblUsers WHERE Username= '" & Me.txtUserName & "'"
strSQL = strSQL & " AND Password= '" & Me.txtPassword & "'"
Set db = CurrentDb
Set rs = db.openrecordset(strSQL)
If rs.BOF Then
'no record found
MsgBox "Incorrect!"
DoCmd.Close acForm, "frmLogins"
'quit access? DoCmd.Quit
Else
MsgBox "Welcome"
DoCmd.Open acForm, "FrmMainMenu"
DoCmd.Close acForm, "frmMain"
End If
Set rs = Nothing
Set db = Nothing
End Sub
When I enter the user name and password on the screen and click on the 'Enter' button I get the following error message;
'Error - User Defined type not defined'
I'm new to the coding part so I have no idea what this means. Can someone please enlighten me...
-----------------------------------------------------------------
St*rlight