Can i use a record as a variable to then place in a query?

carlchapman

Registered User.
Local time
Today, 04:38
Joined
Jul 25, 2006
Messages
29
hi,

Sorry if this thread seems to "layman" for you but i am new to vba and access. OK here is my newest inconvience.

I have built a custom log in form i access, The user names and passwords are stored in a table. When one of the user names selected and password is true they are able to see the main switchboard. Before the switch board is opened, i am trying to create a Msg prompte (Yes or no) to viewing todays records in my chase system with the user name. A query based on todays date and if another box is TRUE is a piece of cake, but i need to clone the user name into the query so that only todays chase' that are relevent to that user are displayed in a chase form.

Ok, here is my "login" VBA.

If IsNull(Me.usrNameInput) Or Me.usrNameInput = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.usrNameInput.SetFocus
Exit Sub
End If

If IsNull(Me.usrPasswordInput) Or Me.usrPasswordInput = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.usrPasswordInput.SetFocus
Exit Sub
End If

If Me.usrPasswordInput.Value = DLookup("usrPassword", "tblUsr", "[salesID]=" & Me.usrNameInput.Value) Then

DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm "Switchboard"

Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.usrPasswordInput.SetFocus
End If

If any 1 has any suggestions or know of a solution to my problem, i would like to here it :) thank you
 
I would either store the username in a global variable, or pass it to an invisible field in the next form (Switchboard) for use (reference by a query).
 

Users who are viewing this thread

Back
Top Bottom