Sorry to bother you all again...
I am trying to create a login page where upon inputting the correct UserName AND password, it would filter a subform below so that they could see only their comments. Is this possible? I have it so that there are two buttons where one checks the Username and Password via VBA code and another button filters using a Macro... But I would like for one button to do everything so that if the password is incorrect, then they cannot see anything. The filter button currently works without a password and as long as there is a correct username it will filter that without looking at the password. I was thinking about just having it click the other button at the end?
I want to say this works but it doesn't after line 25
I am trying to create a login page where upon inputting the correct UserName AND password, it would filter a subform below so that they could see only their comments. Is this possible? I have it so that there are two buttons where one checks the Username and Password via VBA code and another button filters using a Macro... But I would like for one button to do everything so that if the password is incorrect, then they cannot see anything. The filter button currently works without a password and as long as there is a correct username it will filter that without looking at the password. I was thinking about just having it click the other button at the end?
I want to say this works but it doesn't after line 25
Code:
Option Compare Database Option Explicit Private Sub btnLogin_Click() Dim rs As Recordset Set rs = CurrentDb.OpenRecordset("tbl1Employees", dbOpenSnapshot, dbReadOnly) rs.FindFirst "UserName='" & Me.txtUserName & "'" If rs.NoMatch Then Me.lblWrongUser.Visible = True Me.txtUserName.SetFocus Exit Sub End If Me.lblWrongUser.Visible = False If rs!Password <> Nz(Me.txtPassword, "") Then Me.lblWrongPass.Visible = True Me.txtPassword.SetFocus Exit Sub End If Me.lblWrongPass.Visible = False ' Dim SQL As String 'SQL = "SELECT tbl1Comments.comment, tbl1Comments.CommentDate, tbl1Comments.Followup" _ '& "FROM tbl1Comments;" 'Me.subComment.Form.RecordSource = SQL 'Me.subComment.Form.Requery Dim search_text As String search_text = Me.txtUserName If Nz(Me.txtUserName.Value, "") = "" Then Me.FilterOn = False Me.txtUserName.SetFocus Exit Sub End If Me.Filter = "UserName like '*" & Me.txtUserName.Value & "*' or userName like '*" Me.FilterOn = True Me.txtUserName.SetFocus Me.txtUserName.Value = search_text Me.txtUserName.SelStart = Len(Nz(Me.txtUserName.Value, "")) & 1 End Sub
Comment