Tab Control (1 Viewer)

Kyp

Member
Local time
Today, 17:47
Joined
Aug 5, 2021
Messages
77
Hey gang!
I an trying my luck with a tab control within a form.

I only have 2 tables, 2 queries, and 1 form.
The 2 tables tblEmployees, and tblContractors are almost exact.
The 2 queries qryEmployees, and qryContractors are also similar.
The form frmPersonnel has a tab control, with 2 tabs. The first tab is named tabEmployees, and the second tab is named tabContractors.....(see where I'm going with this?)

Is there any way possible I can get the records from the Employees on the tabEmployees, and the records from the Contractors on tabContractors??

I have tried searching the good ole google search machine and have found a few things that I have unsuccessfully tried.
I've read that the record source of all the tabs is the record source of the form itself and that you could not assign a different record source for each tab.
I tried the on click event for each tab utilizing these sub-routines, and have tried it several different ways but no matter what I try, I cannot make it work.....
Is this not possible utilizing a tab control? (not wanting to use sub-form)
Code:
Option Compare Database
Option Explicit

Private Sub tabContractors_Click()
   Form!frmPersonnel.RecordSource = "qryContractors"
End Sub

Private Sub tabEmployees_Click()
   Form!frmPersonnel.RecordSource = "qryEmployees"
End Sub

Cheers!
-Kyp
 

June7

AWF VIP
Local time
Today, 14:47
Joined
Mar 9, 2014
Messages
5,470
Tab control pages don't have a record source, they are just holders for other controls. Subforms are required in order to show different data sources OR a lot of code to not only set the form RecordSource but also ControlSource of data controls, unless tables have exactly same field names.

Even a Navigation Form is essentially a subform container on a main form but there is only one subform loaded at a time by clicking the tab buttons.
 
Last edited:
  • Like
Reactions: Kyp

Kyp

Member
Local time
Today, 17:47
Joined
Aug 5, 2021
Messages
77
Gotcha!
That's pretty much what I've read.
I truly like the look and functionality of the tab control, maybe I can play with a subform design to make it resemble the tab control.

Who am I kidding.....I'm not to that level yet, still figuring out tables!

Cheers!
-Kyp
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 23:47
Joined
Jul 9, 2003
Messages
16,280
You may find my blog on Tab Controls useful:-

 
  • Like
Reactions: Kyp

bastanu

AWF VIP
Local time
Today, 15:47
Joined
Apr 13, 2010
Messages
1,402
You might want to reconsider your design; if the employees and contractors tables are "almost exact" then I think you would be better merging them and adding a Yes\No flag field (IsEmployee or IsContractor). Then your queries would be based on the same table with just different criteria on that field and you could have a toggle button instead of the tab control (to change the record source of the subform and hide\show the controls that pertain to the selected category).
Cheers,
Vlad
 

Users who are viewing this thread

Top Bottom