Run-time error '424': Object required

Gr3g0ry

Registered User.
Local time
Today, 09:00
Joined
Oct 12, 2017
Messages
163
im trying to create a login form and after much research ive gotten this far except i keep getting the above error.

on click of my login button:
Dim dbs As Database
Dim rstUserPwd As Recordset
Dim bfoundMatch As Boolean
Set dbs = CurrentDb
Set rstUserPwd = dbs.OpenRecordSet("qryUserPwd")
bfoundMatch = False

If rstUserPwd.RecordCount > 0 Then
rstUserPwd.MoveFirst

' check for matching records
Do While rstUserPwd.EOF = False
If rstUserPwrd![UserName] = Form_Login.txtusername.Value And rstUserPwrd![Password] = Form_Login.txtpassword.Value Then

bfoundMatch = True
Exit Do
End If

rstUserPwrd.MoveNext
Loop
End If

If bfoundMatch = True Then
'Open the next form here and close this one
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Main"

Else: MsgBox "Incorrect Username and or Password"

End If

can anyone please point out what im doing incorrectly please
 

Attachments

Your recordset isn't correct spelled in more places!
Code:
rstUserPwr[COLOR=Red][B]d[/B][/COLOR]
 
also, instead of using long code, why not use DCount():


If DCount("*","qryUserPwd"," "[UserName] = " & Chr(34) & Form_Login.txtusername.Value & Chr(34) & " And [Password] = " & Chr(34) & Form_Login.txtpassword.Value & Chr(34)) > 0 Then
'Open the next form here and close this one
DoCmd.OpenForm "Main"
DoCmd.Close acForm, Me.Name
Else: MsgBox "Incorrect Username and or Password"
End If
 
Your recordset isn't correct spelled in more places!
Code:
rstUserPwr[COLOR=Red][B]d[/B][/COLOR]

works thanks. now there is a new problem.

i experiment in a new file with the same tables, and data, when the experiment works, i incorporate it into my main project.

iv copied all my now working form, and put it in my main project and the error im now getting is this: Compile error: User-defined type not defined

the debugger point to this line : Dim dbs As Database

any suggestions ?
 
on VBE, check if you have reference
on:

Microsoft Access XX.X Object Library, and,
Microsoft Office XX.X Access database engine Object

if not, add those two.
 
on VBE, check if you have reference
on:

Microsoft Access XX.X Object Library, and,
Microsoft Office XX.X Access database engine Object

if not, add those two.

as always, im not sure what exactly you're referring to. could you please be a bit more specific.
 
go to VBE (press Alt-F11).
on the menu, Tools->Reference, check if the above is not on the ticked list.
add them if not.
 
thanks mi G, like the realest type u came thru once again
 

Users who are viewing this thread

Back
Top Bottom