Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
512 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
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 …

609 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