F
Fev
Hi
I would appreciate some help with creating a subform control on a tab
control in a create form function. I can create the tab control using
the CreateControl command, but I am not getting the subform created on
the specific page of the tab control. Here is the relevant code:
Public Function MyCreateForm()
'Test to create form with tabs and subforms
On Error GoTo ErrorPoint
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim frm As Form
Dim ctlLabel As Control
Dim strName, strCtl As String
Dim ctlData As Control
Dim mdl As Module
Dim lngReturn As Long
Set db = CurrentDb
strName = "tblQNosTemp"
Set tdf = db.TableDefs(strName)
' Create the form and set properties
Set frm = CreateForm
'Code removed with form settings
strName = "frm" & Mid$(tdf.Name, 4, 20)
'Create the tab control in the Detail section of the form.
Set ctlData = CreateControl(frm.Name, acTabCtl, acDetail, "")
ctlData.Name = "ctlFormTab"
ctlData = Nothing
'Create the subform on page 1 referred to as Page(0) on the tab
control
Set ctlData = CreateControl(frm.Name, acSubform, "",
frm.ctlFormTab.Page(0))
ctlData.Name = "ctlSubFormLSM"
DoCmd.Save , strName
DoCmd.Close acForm, strName, acSaveYes
ExitPoint:
Exit Function
ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint
End Function
I would appreciate some help with creating a subform control on a tab
control in a create form function. I can create the tab control using
the CreateControl command, but I am not getting the subform created on
the specific page of the tab control. Here is the relevant code:
Public Function MyCreateForm()
'Test to create form with tabs and subforms
On Error GoTo ErrorPoint
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim frm As Form
Dim ctlLabel As Control
Dim strName, strCtl As String
Dim ctlData As Control
Dim mdl As Module
Dim lngReturn As Long
Set db = CurrentDb
strName = "tblQNosTemp"
Set tdf = db.TableDefs(strName)
' Create the form and set properties
Set frm = CreateForm
'Code removed with form settings
strName = "frm" & Mid$(tdf.Name, 4, 20)
'Create the tab control in the Detail section of the form.
Set ctlData = CreateControl(frm.Name, acTabCtl, acDetail, "")
ctlData.Name = "ctlFormTab"
ctlData = Nothing
'Create the subform on page 1 referred to as Page(0) on the tab
control
Set ctlData = CreateControl(frm.Name, acSubform, "",
frm.ctlFormTab.Page(0))
ctlData.Name = "ctlSubFormLSM"
DoCmd.Save , strName
DoCmd.Close acForm, strName, acSaveYes
ExitPoint:
Exit Function
ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " _
& Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint
End Function