?
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
Medium Priority
?
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 180 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 180 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Suggested Courses

764 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