Automatically creating tabs on a form...

Tina Marie

New member
Local time
Today, 11:03
Joined
Apr 15, 2007
Messages
1
Hello all ... help!!

This may not be the correct way of doing this but .... I have a list box on a form with a value list with numbers from 1 to 20. The user uses the scroll to select a number ... so say they select 5 ... when they do, I want the form to automatically create 5 tabs with all of the same fields on each page? Is this the best way to do it and can it be done? If so, how?

Thanks, Tina
 
What I do there is create all the tabs then Hide Them so when the use selects a number all you need to is loop through the tabs making them visable to the number the use selects then hiding the rest

Hope this helps mod it to your needs
Code:
Sub SetPages()
Dim M_Db As Database
Dim P As DAO.Recordset
Dim StrSQL As String
Dim IntCountControls As Integer
Dim IntLastP As Integer
Dim IntLastPics As Integer
Dim I As Integer

On Error GoTo HandleErr
IntCountControls = 27
If IsNothing(Me![cboGallerys]) Then Exit Sub

StrSQL = "SELECT * FROM QryGalleryPages WHERE [GalleryID]=" & Me![cboGallerys]
Set M_Db = CurrentDb()
Set P = M_Db.OpenRecordset(StrSQL, dbOpenSnapshot)

Me.Painting = False
With P
If .RecordCount <> 0 Then
    .MoveLast
        IntLastP = !pg
        IntLastPics = !C
    .MoveFirst
End If
For I = 1 To IntCountControls
Me.FmPg.Controls.Item(I - 1).Visible = False
Next I

    Do While Not .EOF
    Me.FmPg.Controls.Item(!pg - 1).Visible = True
    If !pg < IntCountControls And IntLastPics = 20 Then
        Me.FmPg.Controls.Item(!pg).Visible = True
    End If
    P.MoveNext
    Loop
End With
Me.Painting = True
Exit_HandleErr:
On Error Resume Next
P.Close
M_Db.Close
Exit Sub

HandleErr:
    Select Case Err.Number
        Case 2467
        Resume Exit_HandleErr
        Case Else
            MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
            Resume Exit_HandleErr
    End Select
End Sub

This is what it looks like this system has a max of 29 Tabs

post-2-1169150435.jpg
 

Users who are viewing this thread

Back
Top Bottom