E
Edward_Whitmore
Dear Access Community:
I am new to Access - especially coding. I looked for the answer to my
question, but wasn't able to find an answer to this exact question. Your
help is much appreciated.
I use the code below to ask the user to enter a manager ID (either 1190 or
20368). The value is stored in the variable InputMgrID. Based on the
response, the program opens one of two forms (frmMgrLvl1 or frmMgrLvl2) based
on two different queries (qryMgrLvl1 and qryMgrLvl2). The form frmMgrLvl1 is
based on query qryMgrLvl1 - and within that query, there is a criterion for
the MgrID field: [Enter manager ID]. So when I run the module, the user is
asked for the manager ID twice - once for the InputBox and once within the
form.
Is there a way to have the query use the value from the InputBox as the
criteria so the user doesn't have to enter the ID twice?
Thank you!
Sub OpenDatabase()
'Ask for manager password, store in variable
Dim InputMgrID As String
InputMgrID = InputBox("Enter Manager ID")
'Choose the form based on the manager ID
Select Case InputMgrID
Case 1190
DoCmd.OpenForm "_frmMgrLvl1", acNormal, "", "", , acNormal
Case 20638
DoCmd.OpenForm "_frmMgrLvl2", acNormal, "", "", , acNormal
Case Else
MsgBox ("Manager not recognized")
End Select
End Sub
I am new to Access - especially coding. I looked for the answer to my
question, but wasn't able to find an answer to this exact question. Your
help is much appreciated.
I use the code below to ask the user to enter a manager ID (either 1190 or
20368). The value is stored in the variable InputMgrID. Based on the
response, the program opens one of two forms (frmMgrLvl1 or frmMgrLvl2) based
on two different queries (qryMgrLvl1 and qryMgrLvl2). The form frmMgrLvl1 is
based on query qryMgrLvl1 - and within that query, there is a criterion for
the MgrID field: [Enter manager ID]. So when I run the module, the user is
asked for the manager ID twice - once for the InputBox and once within the
form.
Is there a way to have the query use the value from the InputBox as the
criteria so the user doesn't have to enter the ID twice?
Thank you!
Sub OpenDatabase()
'Ask for manager password, store in variable
Dim InputMgrID As String
InputMgrID = InputBox("Enter Manager ID")
'Choose the form based on the manager ID
Select Case InputMgrID
Case 1190
DoCmd.OpenForm "_frmMgrLvl1", acNormal, "", "", , acNormal
Case 20638
DoCmd.OpenForm "_frmMgrLvl2", acNormal, "", "", , acNormal
Case Else
MsgBox ("Manager not recognized")
End Select
End Sub