Form with Tab Controls

  • Thread starter Thread starter PR
  • Start date Start date
P

PR

Can anyone advise me on how I can create the following?



I want a Form that I want have a tab control on it, with 3 tabs contain in
it:



1.. Person Details
2.. Membership Details
3.. Sport Details


The database has 3 Tables:



1.. Person Details (PK_person_id)
2.. Membership Details (FK_person_id)
3.. Sport Details (FK_person_id)


I want to know what is the best way to get the data displayed on each tab in
the form, the form will only let me use one data provider, if I do a query
to create this, it will not let me updated the records.



Regards - Paul
 
PR said:
Can anyone advise me on how I can create the following?

I want a Form that I want have a tab control on it, with 3 tabs
contain in it:

1.. Person Details
2.. Membership Details
3.. Sport Details

The database has 3 Tables:

1.. Person Details (PK_person_id)
2.. Membership Details (FK_person_id)
3.. Sport Details (FK_person_id)

I want to know what is the best way to get the data displayed on each
tab in the form, the form will only let me use one data provider, if
I do a query to create this, it will not let me updated the records.

Do this with a main form containing the tab control, and two subforms.
Base the main form on [Person Details], and create separate subforms for
[Membership Details] and [Sport Details]. On the first page of the tab
control, put most of the controls that are bound to the fields in
[Person Details]. Put each of the subforms on a different page of the
tab control. Set the Link Master Fields property of each subform to
PK_persoin_id, and set the Link Child Fields property of each subform to
FK_person_id. That way, the subforms will automatically show the
records related to the current [Person Details] record.
 
Dirk,
Thank you very much for the quick reply, I have done what you suggested and
it works great.

I have one question on the main from, I have put a sub form on for bank
details, when I trying to do a tab order, I need to tab through some of the
personal details then into the bank details on the sub form and then back to
the personal form. I can get to the sub form, but is there a way to get back
to the main form?

Regards - Paul

Dirk Goldgar said:
PR said:
Can anyone advise me on how I can create the following?

I want a Form that I want have a tab control on it, with 3 tabs
contain in it:

1.. Person Details
2.. Membership Details
3.. Sport Details

The database has 3 Tables:

1.. Person Details (PK_person_id)
2.. Membership Details (FK_person_id)
3.. Sport Details (FK_person_id)

I want to know what is the best way to get the data displayed on each
tab in the form, the form will only let me use one data provider, if
I do a query to create this, it will not let me updated the records.

Do this with a main form containing the tab control, and two subforms.
Base the main form on [Person Details], and create separate subforms for
[Membership Details] and [Sport Details]. On the first page of the tab
control, put most of the controls that are bound to the fields in
[Person Details]. Put each of the subforms on a different page of the
tab control. Set the Link Master Fields property of each subform to
PK_persoin_id, and set the Link Child Fields property of each subform to
FK_person_id. That way, the subforms will automatically show the
records related to the current [Person Details] record.


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
PR said:
Dirk,
Thank you very much for the quick reply, I have done what you
suggested and it works great.

I have one question on the main from, I have put a sub form on for
bank details, when I trying to do a tab order, I need to tab through
some of the personal details then into the bank details on the sub
form and then back to the personal form. I can get to the sub form,
but is there a way to get back to the main form?

That can be a pain, can't it? You can press Ctrl+Tab to tab out of the
subform. If you want to avoid having to remember this, or spare your
users the need to remember it, you can add an infinitesimal text box to
the subform (heght 0, width 0), place it last in the tab order on the
subform, and use its GotFocus event to transfer the focus back to a
particular control on the main form. For example:

'----- start of example code -----
Private Sub txtTransfer_GotFocus()

If Me.NewRecord And Not Me.Dirty Then
Me.Parent!ID.SetFocus
Else
Me.ID.SetFocus
DoCmd.GoToRecord , , acNext
End If

End Sub

'----- end of example code -----
 
Dick,
again thank you, can you explain a bit more about your sample code please.

If Me.NewRecord And Not Me.Dirty Then
Me.Parent!ID.SetFocus
Else
Me.ID.SetFocus
DoCmd.GoToRecord , , acNext
End If
 
PR said:
Dick,
again thank you, can you explain a bit more about your sample code
please.

If Me.NewRecord And Not Me.Dirty Then
Me.Parent!ID.SetFocus
Else
Me.ID.SetFocus
DoCmd.GoToRecord , , acNext
End If

"txtTransfer: is the name of a text box I added to the subform to
transfer cointrol to the main form when the user tabs out of the last
control on the subform. As I described above, txtTransfer has a height
and width of 0, so the user can't see it, even though it's technically
visible.

In the form and subform I copied this from, there is a control named ID
on both forms -- "Me.ID" is a reference to the first control on the
subform, while Me!Parent.ID is a reference to the control on the main
form that I want control to go to on tabbing out of the last subform
control. Don't let the names of these controls confuse you; they
aren't important. It's just that one is a target control on the main
form, and one is a target control on the subform.

I wanted to allow the user to enter multiple records on the subform
without leaving the subform, so I wrote the code to only SetFocus out of
the subform if that the user is tabbing from an unmodified, new record.
The lines
If Me.NewRecord And Not Me.Dirty Then
Me.Parent!ID.SetFocus

check to see if the subform is on a new record and that record hasn't
been modified by the user. If both those conditions are true, the focus
is set to the ID control on the subform's parent form; that is, the
main form. (Note that a subform's Parent property returns a reference
to the form containing that subform).

If the conditions are not both true then the Else clause:
Else
Me.ID.SetFocus
DoCmd.GoToRecord , , acNext
End If

sends the focus to the ID control on the subform, and moves to the next
record.
 
Back
Top