Options for passing info to the form to open: 1) OpenArgs argument; 2) filter criteria; 3) TempVars or global variable; 4) set textbox value
Code posted in my link passes value with OpenArgs. I have since modified to apply filter criteria. The Menu form is bound to Users table.
DoCmd.OpenForm "Menu", acNormal, , "UserInitials='" & Me.tbxUser & "'", , acWindowNormal
Then code behind Menu form manages itself to enable/disable buttons and perform other actions:
Code:
Private Sub Form_Open(Cancel As Integer)
Me.cbxUser = Me!UserInitials
If Me!Permissions = "admin" Then
If Not IsNull(DLookup("DateEnter", "UserComments", "Isnull(DateReview)")) Then DoCmd.OpenTable "UserComments"
If Format(Now(), "hhmmss") <= "080000" And Weekday(Date) = 2 And ((Month(Date) >= 6 And Month(Date) <= 9) Or Month(Date) <> Month(DLookup("ConstructionExtract", "Updates"))) Then
ConstructionExtract
End If
End If
If Me!Permissions = "staff" Then
Me.cbxUser.Visible = False
Me.btnAdmin.Visible = False
Me.btnCost.Visible = False
End If
If Me!Permissions <> "admin" Then Call SetAccessXCloseButton(False)
Me.btnSample.SetFocus
End Sub