garethedmondson
Instructor
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
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