AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Trouble Referencing a SubForm Field in a Query

Using MS Access - Trouble Referencing a SubForm Field in a Query


Expert: Scottgem - 5/13/2008

Question
Hi Scott,

I am having a heck of a time referencing a value stored on a field in a subform in a query.  Here are the details:

Main Form: frmItemMaster
Subform: frmOnlineInventorySubform
Field on Subform Containing Value: cmbInventoryLocation

When I open the subform alone (i.e. not when embedded in the main form), I have not trouble with the query referencing the field name as:

[Forms]![frmOnlineInventorySubform]![CmbInvLocation]

However, I cannot find a way to have the query resolve the reference when opening the form as a subform in the main.  Complicating matters is that the subform is residing on a tab control: InventorySubFormTab

I have tried updating the value in the query to the following without luck:

[Forms]![frmItemMaster]![frmOnlineInventorySubform].Form![CmbInvLocation]

Do I need further qualification of the subform field when it resides on a tab control (I've tried to add this as well with no luck)?

Thank you in advance for any help you can provide.

Answer
First, you don't have fields on a form, you have controls that may or may not be bound to a field in a table. This is a subtle but important distinction.

The correct syntax for referencing a value in a control on a subform is:

Forms!formname!subformname.Form.controlname

A Tab control doesn't impact on that.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: MS Office Access 2007 VBA

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.