Hi,
I can't check your code right now but below is a similar code I used once for a login form (no need for the module):
Option Explicit
Dim rs As Recordset
Dim db As Connection
Private Sub cmdCancel_Click()
Me.Hide
Unload Me
End Sub
Private Sub cmdOK_Click()
Set db = New Connection
db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=Manual;uid="";pwd="";"
Set rs = New Recordset
rs.Open "select * from users", db, adOpenStatic, adLockOptimistic
rs.Find "[username] = '" & Me.TXTUserName & "' "
If Not rs.EOF Then
If rs![Password] = Me.TXTPassword Then
frmmain.Show
Unload Me
Else
MsgBox "Invalid Password, try again!", , "Login"
Me.TXTPassword = ""
Me.TXTUserName = ""
TXTPassword.SetFocus
SendKeys "{Home}+{End}"
End If
Else
MsgBox "Invalid Username, try again!", , "Login"
Me.TXTPassword = ""
TXTUserName.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
I hope this will work with you.