A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need help getting query to reference a field in a subform



 
 
Thread Tools Display Modes
  #1  
Old December 30th, 2009, 07:02 PM posted to microsoft.public.access.queries
Mike Daniska
external usenet poster
 
Posts: 1
Default Need help getting query to reference a field in a subform

I am trying to run a query using a specific field in a subform as the
criteria. The query is displaying one combo box from the Form, as well
as several fields from its own subform.

My Form name is: FormGrantManagement
My Subform name is: TableMOA subform
My Subform's subform is: TableCostReports
The field in the subform I want to reference is: MOAID

I have found other help topics that lead me to think that a criteria
along the lines of [Forms]![FormGrantManagement]![TableMOA subform]!
[Form]![MOAID] is what I need to use, and I have tried multiple
variations of this but without success. When I run this query in my
form it prompts me with a parameter query displaying my criteria. If I
type in an actual MOAID number, then the query works, if I click
"Okay" without typing anything in the parameter query I get a query
without any data. Any ideas?

Thanks!

Mike
  #2  
Old December 30th, 2009, 07:38 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Need help getting query to reference a field in a subform

Mike Daniska wrote:

I am trying to run a query using a specific field in a subform as the
criteria. The query is displaying one combo box from the Form, as well
as several fields from its own subform.

My Form name is: FormGrantManagement
My Subform name is: TableMOA subform
My Subform's subform is: TableCostReports
The field in the subform I want to reference is: MOAID

I have found other help topics that lead me to think that a criteria
along the lines of [Forms]![FormGrantManagement]![TableMOA subform]!
[Form]![MOAID] is what I need to use, and I have tried multiple
variations of this but without success. When I run this query in my
form it prompts me with a parameter query displaying my criteria. If I
type in an actual MOAID number, then the query works,



Form is a **property** of subform controls, so that should
be:

Forms!FormGrantManagement![TableMOA subform].Form!MOAID

If that still generates a prompt, check the spelling of each
name carefully.

--
Marsh
MVP [MS Access]
  #3  
Old December 31st, 2009, 03:02 PM posted to microsoft.public.access.queries
Dale Fye
external usenet poster
 
Posts: 2,651
Default Need help getting query to reference a field in a subform

Mike,

You refer to two subforms. Is [TableCostReports] a subform within [tableMOA
subform]? Which of these subforms contains the MOAID field?

Also, you need to use the name of the subform control, not the name of the
object that is the subform. So it might look like:

Forms!FormGrantManagement![TableMOA subform].form.MOAID

as Marshall stated, but if MOAID is on the [TableCostReports] subform, then
it might look like:

Forms!FormGrantManagement![TableMOA
subform].form.[tableCostReports].form.MOAID

the general syntax should look like:

Forms!MainFormName!subformControlName.form.control name
or
Forms!MainFormName!sub1CtrlName.form.sub2CtrlName. form.controlname

----
HTH
Dale



"Mike Daniska" wrote:

I am trying to run a query using a specific field in a subform as the
criteria. The query is displaying one combo box from the Form, as well
as several fields from its own subform.

My Form name is: FormGrantManagement
My Subform name is: TableMOA subform
My Subform's subform is: TableCostReports
The field in the subform I want to reference is: MOAID

I have found other help topics that lead me to think that a criteria
along the lines of [Forms]![FormGrantManagement]![TableMOA subform]!
[Form]![MOAID] is what I need to use, and I have tried multiple
variations of this but without success. When I run this query in my
form it prompts me with a parameter query displaying my criteria. If I
type in an actual MOAID number, then the query works, if I click
"Okay" without typing anything in the parameter query I get a query
without any data. Any ideas?

Thanks!

Mike
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:26 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.