You have a tab control on your form, and you want to set the Caption of its
Pages, based on the values stored in a field in a query?
Yes, you can do that with VBA code. Open Recordset on a query that returns
them in the right record. Loop through the pages and the recordset,
assigning the value from the field to the Caption of the Page while you have
records. If there are not enough records in the query, presumably you want
to hide the remaining tab pages.
The example below assumes a tab control named tabMain, with pages names
pge0, pge1, pge2, ...
Private Sub Form_Open(Cancel As Integer)
Dim rs As DAO.Recordset
Dim strSql As String
Dim iPageKt As Long 'Number of pages in the tab control.
Dim i As Integer
iPageKt = Me.tabMain.Pages.Count
strSql = "SELECT TOP " & iPageKt & " PageName FROM tblPage ORDER BY
PageID;"
Set rs = DBEngine(0)(0).OpenRecordset(strSql)
If rs.RecordCount = 0& Then
Cancel = True
MsgBox "You must set up the pages first."
Else
'Loop through the pages of the tab control.
For i = 0 To iPageKt - 1
With Me("pge" & i)
If rs.EOF Then 'Hide the remaining pages.
If .Visible Then
.Visible = False
End If
Else
If Not .Visible Then
.Visible = True
End If
.Caption = rs!PageName
rs.MoveNext
End If
End With
Next
End If
rs.Close
Set rs = Nothing
End Sub