Solved

Tabbed Pages in Access - How to refer to controls on tabbed pages or refresh a tabbed page Access 2010 VBA

Posted on 2012-03-29
4
447 Views
Last Modified: 2012-04-02
Using Access 2010 ,I had 3 separate forms in a database. All was working fine.

Then it was suggested to me that I should use Tabbed Pages for better navigation.

However in so doing this, some of my functionality has gone off the rails.

I created a New form called frm_main. Then on that form I added a Tab Control called TabCtl0.

On that TabCtl0, I have 3 pages. So I basically dragged and dropped the 3 forms on it's own pages.

So far so good, until I started testing some things.

For instance, on Accounts form I had a lookup combobox  that you enter a value and the record is returned on the screen..

The code I had was on the afterUpdate event was

    Dim lnSearchID As Long
    lnSearchID = cmbo_Search.Column(0)
    DoCmd.OpenForm "frm_Master", acNormal, , "l_ID = " & lnSearchID

But now that form "Frm_Master" is sitting on a page on a tabbed control.

How would I get the form to reload and return the correct record? In other words if that form is now on a another form sitting in a tabbed control, on a page??

Another example is on the form load of another form..I have a subform where a field refers to a date selected on the main form

Batch = Forms!frm_invoiceBatch!txt_ID.Value

The error is can't find referenced form "frm_InvoiceBatch", which tells me I need to refer the tab control, then page , then form..just not sure what the syntax would be.

All this worked till I moved the form to the tabbed pages

Any insight or direction would be much appreciated.
0
Comment
Question by:nomar2
4 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37783696
This is why you can't just "Drop" forms onto subforms/tabcontrols without understanding "Object Referencing"

There are a lot of possible unknowns here...

Can you post an example db that exhibits this issue?
0
 
LVL 77

Accepted Solution

by:
peter57r earned 45 total points
ID: 37784872
First, some general points about referring to subform controls.

The tab control has no bearing on anything.

The issue is that you have gone from 3 main forms, to one main form which holds 3 subforms.

The way you would refer to controls on a subform is quite differrent to the way you refer to controls on a main form.

To refer to a control on a subform you use the syntax...

Forms!Mainformname!subformcontainername.Form!controlname

subformcontainername is the name of the control on the main form that contains the subform.  It might have the same name as the subform but equally it might not.
(The name of the subform is not relevant.)
controlname is the name of the relevant control on your subform

Coming back to your design, though, it sounds to me like you have been given incomplete advice.   If you want the other two forms to match the record in your accounts form then I would say that the Accounts form should be your main form and you drop the other two forms onto that - maybe in a tabcontrol.  But when you add each subform to the accounts main form you will be asked how you want to link the forms together and you can then specify/confirm the matching fields between each pair of forms.  Then the subform data will change to refelect the accounts form record you are looking at.
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 45 total points
ID: 37785284
The issues you have described are not related to the TAB control. It is really related to using sub forms and moving reference to control on sub forms.

I regularly convert forms to use a tab control. I take forms with sub forms that are working properly and add a tab control without any issues. Nothing has to be changed in the VBA code.

here is a good reference by fellow Access MVPs: Refer to Form and Subform properties and controls


Boyd Trimmell, Microsoft Access MVP
0
 

Author Closing Comment

by:nomar2
ID: 37796971
Used ...
=[Forms]![frm_Main]![Invoices].[Form]![txt_BatchDate]

Just a matter of figuring out the Parent form and subform

Also used  Me.RecordSource = "Select * from tMaster where l_ID = " & lnSearchID  which reloaded the subform to the selected record in the dropdown box
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This collection of functions covers all the normal rounding methods of just about any numeric value.
This article will show you how to use shortcut menus in the Access run-time environment.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now