I have a main form named frm_Employees_on_Call_What_Order and on it I have 5 sub forms. Yes, I know, a lot!
I have 3 date forms that if the date is between the current On Call Period then I want to disable the other 3 forms.
Here is my feeble attempt at this; Also I refer to the fields, i.e. controls on the sub-form for my between dates criteria
Example if the current date is Date() and the On Call Period is between 10/18/12 and 10/24/12 then disable the other 3 forms. Not sure if I have to refer to the sub-form like Forms!frm_Employees_on_Call_What_Order![frm_Set_on_call_date].form or something like this ???
Main form is named frm_Employees_on_Call_What_Order
If Date() Between!Forms![frm_Set_on_call_date]![One] and Forms![frm_Set_on_call_date]![seven] Then ' refers to sub form frm_Set_on_call_date
Forms![frm_nextweek].Enabled = False ' sub form on main form frm_Employees_on_Call_What_Order
ElseIf
Forms![frm_weekafter].enable = False 'sub form on main form frm_Employees_on_Call_What_Order
ElseIf
Forms![frm_finalweek].Enabled = False 'sub form on main form frm_Employees_on_Call_What_Order
End If
__________________________________________________ __________________________________________________ ________________________________
Ok, I have finally figured out how to make at least one week's code work.Now though if I try to add the other weeks disable code, it disables all of the command buttons.
The code below disable all of the command buttons if I use it along with the code below it.
'If (Me.one.Value >= Date) Or (Me.two.Value <= Date) Then ' First Week Disable Command Buttons Code
'Me.SecondThursday.Enabled = False 'second week
'Me.SecondWednesday.Enabled = False 'second week
'Me.ThirdThursday.Enabled = False 'third week
'Me.ThirdWednesday.Enabled = False 'third week
'Me.FourthThursday.Enabled = False 'fourth week
'Me.FourthWednesday.Enabled = False 'fourth week
'End If
If (Me.three.Value >= Date) Or (Me.four.Value <= Date) Then ' Second Week Disable Command Buttons Code ' THIS WORKS
Me.FirstThursday.Enabled = False 'first week
Me.FirstWednesday.Enabled = False 'first week
Me.ThirdThursday.Enabled = False 'third week
Me.ThirdWednesday.Enabled = False 'third week
Me.FourthThursday.Enabled = False 'fourth week
Me.FourthWednesday.Enabled = False 'fourth week
End If