I have the following logon modules which I used to direct users with varying priviledges to log on to the DB. I want to be able to populate my support log form with the user ID once the user logs on and open that form. I am thinking about putting in a global variable that would capture the UserID and set to the supportlogs form userID field to this value. I have never used global variables before... any help would be good
LOgon module
SupportlogForm onCurrent event
LOgon module
Code:
Public Sub login() Dim varLog, varPw, varGrp As Variant varLog = DLookup("[userId]", "users", "[logonid]=Forms!login!loginid") varPw = DLookup("[userId]", "users", "[password]=Forms!login!password") If varLog = varPw Then MsgBox ("Login id confirm") varGrp = DLookup("[groupid]", "users", "[password]=Forms!login!password") Else MsgBox ("Invalid LoginID, Try again") loginid.SetFocus End If Select Case varGrp Case 1 DoCmd.Close acForm, "login" DoCmd.OpenForm "mainmenu" Case 2 DoCmd.Close acForm, "login" DoCmd.OpenForm "mangermenu" Case 3 DoCmd.Close acForm, "login" DoCmd.OpenForm "dataentrymenu" End Select End Sub
Code:
Private Sub Form_Current() Dim VarLogon As Variant VarLogon = userID 'this is the global variable I want to set With Me.SupportStaff If Nz(.Value, False) Then Me.SupportStaff.Value = VarLogon End Sub
Comment