PC Review


Reply
Thread Tools Rate Thread

Create a SubForm on a Tab Control

 
 
Fev
Guest
Posts: n/a
 
      1st Mar 2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Value in Tab Page Subform control in Other Tab Ctrl Pg Sbfrm ctrl catrey Microsoft Access Forms 0 3rd Mar 2009 10:10 PM
Referencing control in subform from subform's subform Kat Microsoft Access VBA Modules 5 19th Jun 2006 04:03 PM
How to link a subform to another subform inside a tab control =?Utf-8?B?S2VpdGg=?= Microsoft Access 2 30th Jan 2006 01:37 PM
Tab control with subform containing embedded subform LuvTruth Microsoft Access Forms 2 20th Feb 2004 10:39 PM
How to print a record from a form with its subform(subform on a tab control) Danny Microsoft Access VBA Modules 2 20th Oct 2003 06:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:06 AM.