Where should my code go?

K

Keith

I have a main input form that contains two subforms. The subforms are each
located on a separate page of a Tab Control.

The subforms are all set to show as datasheets. Subform 1 has an after
update that forces variables on the main form to update. This all works
fine.

What I want to do is have the program automatically switch to the second
subform on page 2 if a certain field on subform 1 has been changed. I need
this to be done after the record on subform 1 has been completed.

Where would I need to put this code?

To let you know what I am doing. The database records holidays. Subform 1
records all the holiday requests for the person. If the field that records
the number of public holiday included is set to more than 0 I want the
system to switch over to page 2 that has a subform recording the public
holidays used and free for the person so it can also be updated.
 
M

Marshall Barton

Keith said:
I have a main input form that contains two subforms. The subforms are each
located on a separate page of a Tab Control.

The subforms are all set to show as datasheets. Subform 1 has an after
update that forces variables on the main form to update. This all works
fine.

What I want to do is have the program automatically switch to the second
subform on page 2 if a certain field on subform 1 has been changed. I need
this to be done after the record on subform 1 has been completed.

Where would I need to put this code?

To let you know what I am doing. The database records holidays. Subform 1
records all the holiday requests for the person. If the field that records
the number of public holiday included is set to more than 0 I want the
system to switch over to page 2 that has a subform recording the public
holidays used and free for the person so it can also be updated.


Try using subform1's AfterUpdate event sonething like:

If Me.certainfield > 0 Then
Parent.tabcontrol = 2
Parent.subform2.SetFocus
Parent.subform2.Form.somecontrol.SetFocus
End If

It's probably not that simple if the subform1's record was
edited in a way that does not affect the holiday field.
OTOH, maybe it does need to be done if the number of
holidays is changed.
 
Top