Hello all,
I'm having some difficulty running a Private sub. every time it loads, it gets a run time error "2465" (can't find field 'l1' referred to in your expression.)
Info to help you all get what I'm trying to explain:
Table name = TblUsers
It has 26 fields:
EDIPI = unique ten digit number (primary key assigned)
AdditionalDutiesRosterAdmin = Yes/no
Training = Yes/No
Supply = Yes/No
Those are a few of the fields I'll list for sample data. The tables yes/no fields are what I want to use to give people access to different forms in the database.
Next, I have a form that has a list of buttons that correlate to the yes/no fields in the above mentioned table. On that forms "Private Sub Form_Load()" I'm trying to have it look at the table "TblUsers" EDIPI field and compare it to current user (in code below is Me.Text59). Text59 pulls user name straight from computer with no problems. The problem happens with the second half of the If statement. I want it to look at the record that specifically has the EDIPI and see if the "AdditionalDutiesRosterAdmin" is yes. If it is Yes then the button "CmdAddRoster" will be displayed or if not then it won't display.
Below is the code that I've tried
I'm having some difficulty running a Private sub. every time it loads, it gets a run time error "2465" (can't find field 'l1' referred to in your expression.)
Info to help you all get what I'm trying to explain:
Table name = TblUsers
It has 26 fields:
EDIPI = unique ten digit number (primary key assigned)
AdditionalDutiesRosterAdmin = Yes/no
Training = Yes/No
Supply = Yes/No
Those are a few of the fields I'll list for sample data. The tables yes/no fields are what I want to use to give people access to different forms in the database.
Next, I have a form that has a list of buttons that correlate to the yes/no fields in the above mentioned table. On that forms "Private Sub Form_Load()" I'm trying to have it look at the table "TblUsers" EDIPI field and compare it to current user (in code below is Me.Text59). Text59 pulls user name straight from computer with no problems. The problem happens with the second half of the If statement. I want it to look at the record that specifically has the EDIPI and see if the "AdditionalDutiesRosterAdmin" is yes. If it is Yes then the button "CmdAddRoster" will be displayed or if not then it won't display.
Below is the code that I've tried
Code:
Private Sub Form_Load()
If DCount("*", "[TblUsers]", "[EDIPI] = '" & Me.Text59 & "'") > 0 And ([tblusers]![AdditionalDutiesRosterAdmin] = Yes) Then
CmdAddRoster.Visible = True
Else
CmdAddRoster.Visible = False
End If
End Sub