Disabling SubForms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form named: APPOINTMENTS with various subforms linked named:
App_Subform1, App_Subform2, App_Subform3. On the APPOINTMENTS form the is an
unbound box named: Filterdate which is a date picker. Essentially the
various sub_forms are for taking appointments at certain times of the day
this being dependent on the date selected from Filterdate on the main form.
Each subform has it owe time slot starting at 11am. Some dates selected will
exclude certain times which are presented to the user as stated via
App_Subform2, App_Subform3 etc.

It is possible to either lock or make the App_Subform?? Not be
editable/disabled if their particular time slot is unavailable from the date
the user chooses from Filterdate?

I’m thinking somewhere along the lines of:
iif([Filterdate=Weekday(2),App_Subform.visible/lock.True)

Am I close to the idea and if so where would be the best place to put the
code? Many thanks for taking the time to ready this. Any and all help much
appreciated.

Debbie D.
 
One question first, if the text box is unbound, the next time you open this
record, how do you know which date you have selected, so you can display the
right subform (for edit, not add new record)

Now, for your question
On the after update event of the date field, enter the code

Me.App_Subform1.Visible = (Me.Filterdate=Weekday(1))
Me.App_Subform2.Visible = (Me.Filterdate=Weekday(2))
Me.App_Subform3.Visible = (Me.Filterdate=Weekday(3))

Or To lock it
Me.App_Subform1.Locked= not (Me.Filterdate=Weekday(1))
Me.App_Subform2.Locked= not (Me.Filterdate=Weekday(2))
Me.App_Subform3.Locked= not (Me.Filterdate=Weekday(3))
 
Ofer,

Many thanks for answer now both of my questions. However, this one is
causing me a few problems. I just thought I would try it out first with a
text box to hide it first. Here is what I put in: I had to put this in on
the FilterDate on Exit as a procedure as I couldn't find where to put in on
the UpDate as there is already a =ShowFilter in there and it wouldn't let get
to the Procedure VBA part? It works fine once but I go back and change the
FilterDate, date to Monday date value it will will still remain hidden. Any
ideas. In total I have five of these time values to hide Time2 to Time7 will
I just repeat the comands or will I need some sort of loop? Many thanks
again you are being a great help. Debbie D.

Me.Time2.Visible = (Me.FilterDate = Weekday(2))

Ofer said:
One question first, if the text box is unbound, the next time you open this
record, how do you know which date you have selected, so you can display the
right subform (for edit, not add new record)

Now, for your question
On the after update event of the date field, enter the code

Me.App_Subform1.Visible = (Me.Filterdate=Weekday(1))
Me.App_Subform2.Visible = (Me.Filterdate=Weekday(2))
Me.App_Subform3.Visible = (Me.Filterdate=Weekday(3))

Or To lock it
Me.App_Subform1.Locked= not (Me.Filterdate=Weekday(1))
Me.App_Subform2.Locked= not (Me.Filterdate=Weekday(2))
Me.App_Subform3.Locked= not (Me.Filterdate=Weekday(3))

--
I hope that helped
Good luck


Debbie D. said:
I have a main form named: APPOINTMENTS with various subforms linked named:
App_Subform1, App_Subform2, App_Subform3. On the APPOINTMENTS form the is an
unbound box named: Filterdate which is a date picker. Essentially the
various sub_forms are for taking appointments at certain times of the day
this being dependent on the date selected from Filterdate on the main form.
Each subform has it owe time slot starting at 11am. Some dates selected will
exclude certain times which are presented to the user as stated via
App_Subform2, App_Subform3 etc.

It is possible to either lock or make the App_Subform?? Not be
editable/disabled if their particular time slot is unavailable from the date
the user chooses from Filterdate?

I’m thinking somewhere along the lines of:
iif([Filterdate=Weekday(2),App_Subform.visible/lock.True)

Am I close to the idea and if so where would be the best place to put the
code? Many thanks for taking the time to ready this. Any and all help much
appreciated.

Debbie D.
[/QUOTE]
 
Hi Debbie
I assume that the ShowFilter it a function you are running, on the after
update event.
Remove this line, get into the code section and write

' Run the function
ShowFilter
' Check the week day
Me.Time2.Visible = (Weekday(Me.FilterDate) = Weekday(2))
....
....
....
--
I hope that helped
Good luck


Debbie D. said:
Ofer,

Many thanks for answer now both of my questions. However, this one is
causing me a few problems. I just thought I would try it out first with a
text box to hide it first. Here is what I put in: I had to put this in on
the FilterDate on Exit as a procedure as I couldn't find where to put in on
the UpDate as there is already a =ShowFilter in there and it wouldn't let get
to the Procedure VBA part? It works fine once but I go back and change the
FilterDate, date to Monday date value it will will still remain hidden. Any
ideas. In total I have five of these time values to hide Time2 to Time7 will
I just repeat the comands or will I need some sort of loop? Many thanks
again you are being a great help. Debbie D.

Me.Time2.Visible = (Me.FilterDate = Weekday(2))

Ofer said:
One question first, if the text box is unbound, the next time you open this
record, how do you know which date you have selected, so you can display the
right subform (for edit, not add new record)

Now, for your question
On the after update event of the date field, enter the code

Me.App_Subform1.Visible = (Me.Filterdate=Weekday(1))
Me.App_Subform2.Visible = (Me.Filterdate=Weekday(2))
Me.App_Subform3.Visible = (Me.Filterdate=Weekday(3))

Or To lock it
Me.App_Subform1.Locked= not (Me.Filterdate=Weekday(1))
Me.App_Subform2.Locked= not (Me.Filterdate=Weekday(2))
Me.App_Subform3.Locked= not (Me.Filterdate=Weekday(3))

--
I hope that helped
Good luck


Debbie D. said:
I have a main form named: APPOINTMENTS with various subforms linked named:
App_Subform1, App_Subform2, App_Subform3. On the APPOINTMENTS form the is an
unbound box named: Filterdate which is a date picker. Essentially the
various sub_forms are for taking appointments at certain times of the day
this being dependent on the date selected from Filterdate on the main form.
Each subform has it owe time slot starting at 11am. Some dates selected will
exclude certain times which are presented to the user as stated via
App_Subform2, App_Subform3 etc.

It is possible to either lock or make the App_Subform?? Not be
editable/disabled if their particular time slot is unavailable from the date
the user chooses from Filterdate?

I’m thinking somewhere along the lines of:
iif([Filterdate=Weekday(2),App_Subform.visible/lock.True)

Am I close to the idea and if so where would be the best place to put the
code? Many thanks for taking the time to ready this. Any and all help much
appreciated.

Debbie D.
[/QUOTE]
 
Back
Top