Hi,
I'm trying to make code for password check in Access2007.
The user type and password are stored in table (id,name,psw)(Defined in other database)
A form opens with 2 fields, Listbox User (to select username-type) and Textbox Password. On password enter modul runs. It stucks somewhere in the loop, and the Access closes.
The modul:
Public Function Pass()
Dim dbsmain As DAO.Database
Dim rstRecord As DAO.Recordset
Dim strSQL, strUserR, strUserE, strPassE, strPassR As String
On Error GoTo ErrorHandler
strUserE = Forms!Password!User
strPassE = Forms!Password!Password
strUserR = ""
strPassR = ""
Set dbsmain = CurrentDb
'Open a recordset on all records from the tblLogin table
strSQL = "SELECT * FROM tblLogin"
Set rstRecord = dbsmain.OpenRecordset(strSQL, dbOpenDynaset)
With rstRecord
Do Until .EOF
strUserR = rstRecord![Name]
If strUserR = strUserE Then
strPassR = rstRecord![Psw]
End If
Loop
End With
rstRecord.Close
dbsmain.Close
Set rstRecord = Nothing
Set dbsmain = Nothing
Exit Function
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function
Afterwards, regarding to strUserE value, it will open different menue to continue.
I cant find where it stucks,
Thanks
I'm trying to make code for password check in Access2007.
The user type and password are stored in table (id,name,psw)(Defined in other database)
A form opens with 2 fields, Listbox User (to select username-type) and Textbox Password. On password enter modul runs. It stucks somewhere in the loop, and the Access closes.
The modul:
Public Function Pass()
Dim dbsmain As DAO.Database
Dim rstRecord As DAO.Recordset
Dim strSQL, strUserR, strUserE, strPassE, strPassR As String
On Error GoTo ErrorHandler
strUserE = Forms!Password!User
strPassE = Forms!Password!Password
strUserR = ""
strPassR = ""
Set dbsmain = CurrentDb
'Open a recordset on all records from the tblLogin table
strSQL = "SELECT * FROM tblLogin"
Set rstRecord = dbsmain.OpenRecordset(strSQL, dbOpenDynaset)
With rstRecord
Do Until .EOF
strUserR = rstRecord![Name]
If strUserR = strUserE Then
strPassR = rstRecord![Psw]
End If
Loop
End With
rstRecord.Close
dbsmain.Close
Set rstRecord = Nothing
Set dbsmain = Nothing
Exit Function
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function
Afterwards, regarding to strUserE value, it will open different menue to continue.
I cant find where it stucks,
Thanks