Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab Control on Form 1

Status
Not open for further replies.

pakaymc

Programmer
Jun 18, 2002
1
US
I am using the 'Tab Control' on a form that has 5 different tabs. Each tab displays data from a separate table. When I change the record on the first tab, I need to display the data on each tab that is related to the record on the first tab.

When I change tabs, the data is displayed for the first record in the database not the current record on tab one. How can I link each tab to the current record on tab one?

Any help would be appreciated.
 
Sorry I don't have a lot of time, but in the On Click event of the tab's individual pages do something like the following: Set up a recordset clone of your table and use the recordset clone to find the record matching your page 1 table key. Then bookmark the table to it and it should be syncronized.

Hope this at least gets you started. Lunch is over and work awaits.

Good Luck!

 
If the other tabs have subform on them, you could use the link child field (Present Tab) and the link master field (Tab 1) on in the property of the subform.
 
Hi pakaymc,
Did you ever got your problem solved because I'm having the same problem.

Anna
:)
 
I had this same problem, and many things I tried, as well as many suggestions, failed. Finally, blarson0 found the solution to my problem, and based on that, I think the following should help you:

Put the same control on all five forms, something like record_id. It should be something that only has one value per record. If the user inputs this value, then you can have them do that on the first form, and on all the others, put a text box with record_id as the control source, and set them to invisible, or not enabled, depending on how you want them to act.

Now, in your properties window (press {F4} or double-click something on the form if it's not open), go up to the list box at the top, and find the name of your tab control, which should be something like TabCtrl0
or tab_control0 or something similar. Set its on change event to event procedure.

Now, in the Visual Basic code, put something similar to this in:

Code:
If
Code:
[tab control]
Code:
.Value = 1 Then
    Me.Form.RecordSource = "SELECT * FROM [
Code:
Table name
Code:
] WHERE ( [
Code:
record_id
Code:
] = '" &
Code:
[tab control]
Code:
.Pages(0).Controls!Form.Controls!
Code:
record_id
Code:
 & "' );"
Else
    ...
EndIf

Change
Code:
[tab control]
to the name of your tab control, and change
Code:
Table name
to the name the table you have
Code:
record_id
stored in.

The preceding code checks to see which tab you've entered when you change tabs, and whatever record is open on the first page, it will open on the second. Just repeat this code in the if statement for each tab where you want to load records based on the other tabs. I've discovered that tab control pages are really annoying. So this may not even work for you.. the version I have has various subforms on each page, so I had to set the RecordSources on each of those according to the subforms. But it should be basically the same if you just have main forms on each tab page. Also, the tabs are numbered so that pages(0) is the first one on the left, pages(1) is the one after that, etc.

I hope this is helpful! To see the process I went through and the different things I tried (maybe something in there will work better for you than it did for me), go to thread702-327263 47 is a magical number. 47 plus 2 equals 49. 47 times 2 equals 94. 49 and 94. 94 and 49. Relationship between 47 and 2: it's magic.
 
Thank you soooo much for taking the time to make a suggestion. I will definitely give it a shot. It seems so easy when you think about how all the underlying tables are linked by an id yet the forms won't transfer the id numbers unless you save and then go back in. Odd.

Anyway I will post my results.
Thanks again. Anna :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top