Subform location on Tab Control

dkaib

New member
Local time
Today, 18:13
Joined
Jun 7, 2003
Messages
9
I have a form with 4 tabs that contain 4 subforms.

I would like each subform to start in the same spot on the tab.

Is there any way to force this or lock the starting position of the subform on the tab control?

Everytime I try to get the subforms aligned, one of the other subforms moves up or down.

Any help will be appreciated.

Thanks in advance,
Dan
 
Hi Dan and welcome to the site.

You could try setting the dimensions of SubForms 2, 3 and 4 equal to SubForm1.


Code:
Option Explicit
Option Compare Text


Private Sub Form_Open(ByRef intCancel As Integer)
    
    Me.frmSubForm2.Top = Me.frmSubForm1.Top
    Me.frmSubForm3.Top = Me.frmSubForm1.Top
    Me.frmSubForm4.Top = Me.frmSubForm1.Top
    
    Me.frmSubForm2.Left = Me.frmSubForm1.Left
    Me.frmSubForm3.Left = Me.frmSubForm1.Left
    Me.frmSubForm4.Left = Me.frmSubForm1.Left
    
    Me.frmSubForm2.Width = Me.frmSubForm1.Width
    Me.frmSubForm3.Width = Me.frmSubForm1.Width
    Me.frmSubForm4.Width = Me.frmSubForm1.Width
    
    Me.frmSubForm2.Height = Me.frmSubForm1.Height
    Me.frmSubForm3.Height = Me.frmSubForm1.Height
    Me.frmSubForm4.Height = Me.frmSubForm1.Height
    
End Sub
That way you could manually position to SubForm1 and others would follow.

Hope that helps.

Regards
Chris
 
Thanks for the reply Chris.

That should do the trick, my only other question is where to put the code.

Would it go on the On Change Event in the Tab Control with Code Builder or something on the individual tab Pages?

Thanks,
Dan
 
When I tested it, it worked straight in the Form_Open event of the Form that contains the Tab control.

Regards Chris
 
Chris,

I put the code in the main form, in the On Open event using Code Builder.

When the code executes I get a Compile Error:
Method or data member not found.
Help says it is Error 461.

It stops on fsubAlumniServices.
If I delete fsubAlumniServices from the code, it stops on
fsubAlumniClassProjects.
It passes fsubAlumniEvents without error.

The subforms fsubAlumniServices and fsubAlumniClassProjects exist and are spelled correctly.

Below is the code as I have it entered:
Option Explicit
Option Compare Text


Private Sub Form_Open(ByRef intCancel As Integer)

Me.fsubAlumniEvents.Top = Me.fsubAlumniCommittees.Top
Me.fsubAlumniServices.Top = Me.fsubAlumniCommittees.Top
Me.fsubAlumniClassProjects.Top = Me.fsubAlumniCommittees.Top

Me.fsubAlumniEvents.Left = Me.fsubAlumniCommittees.Left
Me.fsubAlumniServices.Left = Me.fsubAlumniCommittees.Left
Me.fsubAlumniClassProjects.Left = Me.fsubAlumniCommittees.Left

Me.fsubAlumniEvents.Width = Me.fsubAlumniCommittees.Width
Me.fsubAlumniServices.Width = Me.fsubAlumniCommittees.Width
Me.fsubAlumniClassProjects.Width = Me.fsubAlumniCommittees.Width

Me.fsubAlumniEvents.Height = Me.fsubAlumniCommittees.Height
Me.fsubAlumniServices.Height = Me.fsubAlumniCommittees.Height
Me.fsubAlumniClassProjects.Height = Me.fsubAlumniCommittees.Height

End Sub

Following the Me. is the subform name. I don't know enough of Access to determine what is wrong based on the error given.

I'm using Access 2002 but the database is Access 2000 file format.

Thanks for your help,
Dan
 
Hi Dan

There's an A97 demo attached.

I think the problem is in the names used. Remember the names are the names of the Controls that contain the Sub Forms. In the demo I have used your names for the Sub Form Controls and my names for the Sub Forms.

Hope it converts OK.

Regards
Chris
 

Attachments

Hi Pat

Yes, I don't know what the original problem is but I suspect that snap to grid may have something to do with it. (Never use snap to grid myself so I have no experience with it.) It's really just a work-around but it does allow for the positioning and sizing of the first Sub Form control and the others will follow precisely.

Regards
Chris
 
Thanks Chris, your example did the trick.

My problem was there are so many names and properties, I could not find the subform properties.

Thanks again,
Dan
 

Users who are viewing this thread

Back
Top Bottom