Solved How to create command button on tab control with vba in design mode on click from other form

I can assure you it wasn't easy!

This has been a very interesting exercise! I think it was 5 years ago I looked at this, so my recollection was vague to say the least... It is clear to me now that the problem I had with this code the first time around was my assumption that a Tab control contained pages. I spent a lot of time trying to find the code that would access the "collection of controls" - the "pages" within the Tab control. But a Tab control just doesn't work like that, the pages are separate pages, it's as if the pages are independent from the Tab control. You can test this yourself by putting two tab controls on a form and then try and name any two tabs with the same name that is tabs from either Tab control if your name " page1" on the first Tab control and "page1" on the second Tab control then you will get a clash.
 
Again this is a dumb idea for a lot of reasons. Not sure what part of dumb idea is confusing. There are much easier and much better ways to do this. It is a real good way to corrupt your db, but what do I know.

There are only two tricks.
1) You cannot call this code from the same form you plan to edit. Even if the code is in another module.
2) You need to set the Parent property by name. In the case of a tabctl it is a Page name.

I think Uncle Gizmo demonstrated all that is needed. I added a couple bells and whistles, but does not really add to the concept.
 

Attachments

i need one hint that is it possible with vba to create command button on tab control on pages...... than i will move..on

mnaeem90,
Yes, it is possible to do with one major limitation. You can NEVER compile the front end into a mde/accde for deployment if your code will need to open any form in the design view in production/live.

Something to keep in mind if you ever want to protect your forms after deployment.
 
Last edited:
I want to create button on tab control with VBA from different form. When i click to create button than with vba other form will open in a design view and create button on specific tab page.

So have you done it?

Do you need more help?
 
thank you so much...i lost hope that it is possible in MS access and just saw reply mail today..

i want to know other than these forms where i can study VBA related to MS access

Above code is working till creation of button but VBA remain's open.
 
thank you so much...i lost hope that it is possible in MS access and just saw reply mail today..

i want to know other than these forms where i can study VBA related to MS access

Above code is working till creation of button but VBA remain's open.

found answer
Application.VBE.MainWindow.Visible = False
 

Users who are viewing this thread

Back
Top Bottom