Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If then else I have form with fields: Date, OT1 i want to disable the OT1 field

ID: 3560724 • Letter: I

Question

If then else

I have form with fields:

Date, OT1

i want to disable the OT1 field if the the day if FRIDAY on the particular date.

for this i have created a text field with the name "Weekname" and the expression i put in it

=WeekdayName(Weekday([date],1))

and on afterupdate control i put the following code, but nothing happen, i have a very littel knowledge of VB coding, so please help

Private Sub Weekname_AfterUpdate()

If Me.Weekname = "Friday" Then

Me.OT1.Enabled = False

Else
Me.OT1.Enabled = True

End If

End Sub

Explanation / Answer

..W@#hich control are you refering to that has the afterupdate?

also using "date" as a control name is a NoNo . .

date is a reserved word and refers to the date() function.

if this is a payroll form - give it a name of say . . PayDate or WorkDate

put the code in the afterupdate of WorkDate.,/

Me.OT1.Enabled = Not ((Weekday(Me.WorkDate, 1)) = 6)

6 is the value for friday

I tested this out on a dummy form and works ok for me..