Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Password Code

Status
Not open for further replies.

garethedmondson

Instructor
Dec 1, 2003
6
GB
Hi Guys,

I have worked on a piece of code which is called when a button is pressed. The code is below:

Public Function GetPassword(ByVal UserName As String) As String
On Error GoTo PasswordError
Dim strSQL As String
Dim rs As Recordset

strSQL = "SELECT password FROM tbl_users WHERE UserName = '" & UserName & "'"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)

GetPassword = rs!password
rs.Close
Set rs = Nothing
Exit Function

password Error:
Select Case Err.Number
Case 3021
MsgBox "Invalid User! Please try again!", , "Authentication Error"
End Select
End Function


When I press the button, I get Access reporting that a variable is not defined - this variable is dbOpenDynaset - you can see it in the lines above. Where exactly should I be defining this?

Regards

Gareth
 
dbOpenDynaset is a defined constant that is part of the DAO object.
Check your references (click tools->references and make sure you have set a reference next to Microsoft DAO 3.6 (or 3.5 depending on your system)

That should sort it for you.

hth

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Hi Ben,

Many thanks for the reply. However if I load Access and follow the Tools menu at the top, there is no option 'References' there.

Am I missing something?

I am using Access 2002

Cheers

Gareth
 
You need to be in the code screen.
Press alt+F11 to open it.

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Hi Ben,

Cheers mate. Got it and done it. Everything is now working.

Best wishes

Gareth Edmondson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top