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
465 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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 …

816 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

12 Experts available now in Live!

Get 1:1 Help Now