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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Tab style Forms

Status
Not open for further replies.

Ktx7ca

IS-IT--Management
Apr 5, 2008
88
CA
I'm looking for a way to auto create the corect number of tab forms based on information returned from a query.

any ideas?

thanks chris
 
It ain't pretty but something like this should work. On the button used to open your form try this:

Code:
Dim intExistingTabs As Integer
Dim intRequiredTabs As Integer
Dim intloop As Integer


y = InputBox("number of tabs")
DoCmd.OpenForm "frmMyTabs", acDesign, , , , acHidden
x = Forms!frmMyTabs.MyTabctl.Pages.Count

If intExistingTabs < intRequiredTabs Then
    For intloop = intExistingTabs To intRequiredTabs - 1
        Forms!frmMyTabs.MyTabctl.Pages.Add
    Next intloop
Else
    For intloop = intRequiredTabs To intExistingTabs - 1
        Forms!frmMyTabs.MyTabctl.Pages.Remove
    Next intloop
End If
    
 DoCmd.OpenForm "frmMyTabs"

Is this what you mean? Naturally you will need to replace the input box with your query to get number of required tabs and i presume you will want to add some logic to give the tabs sensible names...

JB
 
HI JB

Thanks for the code, I seam of have a a bit of a problem. It wants Y an X defined, I got Y working but I can;t seam to get X defined correctly.

thanks chris
 
How are ya Ktx7ca . . .

Posting the all knowing SQL of the query would speed things up quite a bit! [thumbsup2]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I hav'nt made the query yet just trying o get it to work with me just giving it the number of tabs each witha list box on it.

I just wanted to get the basic working before I complecated the situation.
 
ktx: How embarrasing. I chugged out the code using old fashioned x and y variables then named them sensiby but missed those two at the top! Replace y with intRequiredTabs and x with intExistingTabs and then colour me embarrased....

JB
 
OK Now that I woke opened my eyes and read the code it works fine. OK now it's time to make the query and figure out how to put the data in the tabs name and the lists boxes


 
ktx: May I make a suggestion? If you're going to have list boxes etc on the pages of this tab control then they would need to be created dynamically. Perhaps a smarter move would be to create a tab form with more than maximum amount of required tabs and then adjust my code to turn the visible property on or off as required?
 
Not to worry I didn't notice it at first either, it wasn't untill I came back to it and reread it did it dawn on me.

chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top