beginner123
Registered User.
- Local time
- Today, 12:23
- Joined
- Apr 13, 2013
- Messages
- 44
HI All,
I have created a Navigation form with a NavigationControl0.
Certain Navigation buttons are set to Enabled -No
I have another form ** Login ** where if the user logs in corretly I would like to enable a certain navigation button.
The is a cmdOK button on the Login form which On Click Event Procedure
Private Sub cmdOK_Click()
Dim rs As Recordset
Dim strSQL As String
Dim strPassword As String
Dim strUserName As String
Dim Userlogged As Boolean
On Error Resume Next
strUserName = Username.Value
strPassword = Password.Value
Set db = CurrentDb
strSQL = "SELECT password FROM sUser WHERE username='" & strUserName & "'"
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
If rs.Fields(0) <> strPassword Then
MsgBox "Wrong username or password. Try again.", vbOKOnly, "Warning!"
Else
Me.Visible = False
'Userlogged = True
Username.Value = ""
Password.Value = ""
NavigationButton140.Enabled = True
MsgBox "Should be Enabled but isn't!", vbOKCancel
End If
Else
MsgBox "Wrong username or password. Try again.", vbOKCancel, "Warning!"
Username.Value = ""
Password.Value = ""
Username.SetFocus
End If
End Sub
Can someone please help or guide me in the right direction!
Many thanks
I have created a Navigation form with a NavigationControl0.
Certain Navigation buttons are set to Enabled -No
I have another form ** Login ** where if the user logs in corretly I would like to enable a certain navigation button.
The is a cmdOK button on the Login form which On Click Event Procedure
Private Sub cmdOK_Click()
Dim rs As Recordset
Dim strSQL As String
Dim strPassword As String
Dim strUserName As String
Dim Userlogged As Boolean
On Error Resume Next
strUserName = Username.Value
strPassword = Password.Value
Set db = CurrentDb
strSQL = "SELECT password FROM sUser WHERE username='" & strUserName & "'"
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
If rs.Fields(0) <> strPassword Then
MsgBox "Wrong username or password. Try again.", vbOKOnly, "Warning!"
Else
Me.Visible = False
'Userlogged = True
Username.Value = ""
Password.Value = ""
NavigationButton140.Enabled = True
MsgBox "Should be Enabled but isn't!", vbOKCancel
End If
Else
MsgBox "Wrong username or password. Try again.", vbOKCancel, "Warning!"
Username.Value = ""
Password.Value = ""
Username.SetFocus
End If
End Sub
Can someone please help or guide me in the right direction!
Many thanks