Security - help!

  • Thread starter Thread starter starlight
  • Start date Start date
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...

:rolleyes:
-----------------------------------------------------------------
St*rlight

:)
 
Your computer is not set up to use DAO. You will need to set a reference to DAO.

  • Open a module;
  • Select Tools -> References;
  • Check: Microsoft Data Access Objects 3.6;
  • Move it's priority to above Microsoft ActiveX Data Objects;
  • It should work now;
  • :cool:
 
:)

And it does!!

Thanks v.much. Your help is much appreciated :)

-----------------------------------------------------
St*rlight
:)
 
Bear in mind that DAO is the Access 97 method of data access.
Refer to this thread to see how the latest version, ADO compares in the basics to DAO.
 
Help Please ??

Hi,
I just used the security code that was here.. Its really good.. Anyways here is my code:

Private Sub Command4_Click()

Dim db As Database
Dim rs As Recordset
Dim strSQL


strSQL = "SELECT * FROM unamepass WHERE uname= '" & Me.uname & "'"
strSQL = strSQL & " AND Password= '" & Me.pass & "'"

Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If rs.BOF Then
MsgBox "Incorrect!"
Else
MsgBox "Welcome"
End If

Set rs = Nothing
Set db = Nothing


End Sub

The Error message i am getting is:
Run-time error '3061'
Too few parameters. Expected 1.

Thanx
 

Users who are viewing this thread

Back
Top Bottom