Storing Username as variable upon login

Best Microsoft Access Programmer Portland OR

Created a login form that checks to a table to validate username and subsequent password and opens a form at the end of it all.

My thought was to store the username entered as a variable that i can call upon later to use that username ex:when entering a sale entry ill be able to call the variable to make note of who made the entry in a separate field and possibly run queries off that main sales database to filter sales by User/Person

I hope this makes sense or that I’m approaching it from the right way but feel that I’m over complicating things for myself – I’m sitting at my desk all day and am more than willing to clarify anything that was badly explained or to provide additional information

Code below is my login btn click event. Completely lost to where i should be declaring variables in this form

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 = True Then Me.lblWrongUser.Visible = True Me.txtUserName.SetFocus Exit Sub End If Me.lblWrongUser.Visible = False If rs!Password <> Me.txtPassword Then Me.lblWrongPass.Visible = True Me.txtPassword.SetFocus Exit Sub End If Me.lblWrongPass.Visible = False DoCmd.OpenForm "frmAdminPage" DoCmd.Close acForm, Me.Name End Sub 

Any help is much appreciated thanks again!

submitted by /u/EatMyPenta
[link] [comments]

Microsoft Acess Developer Portland OR