Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2005

Tip: Looking for answers? Try searching our database.

Got a TabControl. Add a page. Now create a new control and glue it to the page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phlip - 28 Jul 2005 19:59 GMT
Access forms coding:

Ogle this sample code from threads of yore:

Public Sub NewTab()
   Dim newpage As Page
   Dim ctlTab As Control
   Dim frmTab As Form

   DoCmd.OpenForm "frmTab", acDesign
   Set frmTab = Forms("frmTab")
   Set ctlTab = frmTab.Controls("TabControl")

   Debug.Print "before pages.count = " & ctlTab.Pages.Count
   Set newpage = ctlTab.Pages.Add

   Debug.Print "after pages.count = " & ctlTab.Pages.Count
   DoCmd.Save acForm, "frmTab"
   DoCmd.OpenForm "frmTab", acNormal

   Set newpage = Nothing
   Set ctlTab = Nothing
   Set frmTab = Nothing
End Sub

Notice the programmer did nothing with 'newpage'.

I want to do something with it! How can I push a new control into it?
newpage.Controls.Add does not exist.

Signature

 Phlip
 http://www.c2.com/cgi/wiki?ZeekLand

Marshall Barton - 28 Jul 2005 21:52 GMT
>Access forms coding:
>
[quoted text clipped - 25 lines]
>I want to do something with it! How can I push a new control into it?
>newpage.Controls.Add does not exist.

You would refer to the page in the CreateControl function.

If you are thinking of doing this at run time (instead of as
a little helper procedure at design time), forget this idea
and precreate the controls and manipulate their Visible
property at run time.

Signature

Marsh
MVP [MS Access]

tyrdrannoy - 28 Jul 2005 22:25 GMT
you missed the line of code where the programmer did use newpage:
Set newpage = ctlTab.Pages.Add

that will add a new tab

> Access forms coding:
>
[quoted text clipped - 25 lines]
> I want to do something with it! How can I push a new control into it?
> newpage.Controls.Add does not exist.
Brendan Reynolds - 28 Jul 2005 22:47 GMT
From a recent thread ...

Newsgroups: microsoft.public.access.modulescoding
Subject: Re: Creating controls on a page object
Date: Sun, 17 Jul 2005

Public Sub TestSub4()

   Dim frm As Form
   Dim tbc As TabControl
   Dim pge As Page
   Dim txt As TextBox

   DoCmd.OpenForm "Form2", acDesign
   Set frm = Forms("Form2")
   Set tbc = frm.Controls("TabCtl0")
   Set pge = tbc.Pages.Add()
   pge.Name = "MyNewTabPage"
   pge.Caption = "My New Tab Page"
   CreateControl frm.Name, acTextBox, _
       acDetail, pge.Name, "=Now()", _
       pge.Left + 50, pge.Top + 50, 2000, 250

   DoCmd.Close acForm, "Form2", acSaveYes

End Sub

Signature

Brendan Reynolds (MVP)

> Access forms coding:
>
[quoted text clipped - 25 lines]
> I want to do something with it! How can I push a new control into it?
> newpage.Controls.Add does not exist.
Phlip - 29 Jul 2005 00:08 GMT
Thanks, but...

>     DoCmd.OpenForm "Form2", acDesign

...sorry, dude. I have to move the goalpost. I need the feature in running
mode, not design mode. (Like all the other TabControls on the planet...)

I suspect, per other threads, that I can't do that, and I am expected to use
a function like yours, at design time, to blast in a thousand tabs, make
them all invisible, and visible the populated ones at runtime.

What I actually need is a "filmstrip" control, like the one in the Windows
Explorer. So what I will eventually do is put 10 pages into a virtual
TabControl, and repopulate the labels as the users navigate back and forth.

>     CreateControl frm.Name, acTextBox, _
>         acDetail, pge.Name, "=Now()", _
>         pge.Left + 50, pge.Top + 50, 2000, 250

CreateControl was the missing function! Now I remember using it 8 years ago.
Friggin' Alzheimers...

Signature

 Phlip
 http://www.c2.com/cgi/wiki?ZeekLand

Brendan Reynolds - 29 Jul 2005 11:38 GMT
You're right - you can't do that.

Controls can only be created in design view. Also, there's a limit of 754
controls or sections added over the lifetime of the form, which you'd
eventually hit if you created controls each time the form was opened.

You'll need to create the maximum number of controls you may ever need at
design time, and toggle their visibility at run time.

I've read that if you open a form in design view, create controls, switch to
form view, and then when closing the form do not save the new controls, they
do not count toward the 754 limit. But I have not tried this myself. The
form would still have to be opened in design view first, which means that it
will not work in an MDE, or using a runtime installation, or where the user
does not have change design permission on the form.

Signature

Brendan Reynolds (MVP)

> Thanks, but...
>
[quoted text clipped - 20 lines]
> ago.
> Friggin' Alzheimers...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.