Query in a bound Form to unbound fields (1 Viewer)

weilerdo

Registered User.
Local time
Today, 11:28
Joined
Apr 21, 2005
Messages
109
I have a form frm_austin_logs that is bound to a table tbl_logs on the form I have 8 fields that are not bound to the table that I want to pull there information from a query. I created the query qry_austin_log_gpa and if I run the query stand alone it works fine. In the form I put the following code in the Control Sourse for the unbound field
=[qry_austin_log_gpa]![English] and I get the #Name? error in the field. I am completely stumped on this one. I even tried doing it in VB code Me.Text50 = Nz(Avg(IIf([subjest] = Math And [student] = Austin, [score])), From("[tbl_logs]")) with no luck. The query field that works stand alone is the following. Math: Nz(Avg(IIf([subjest]='Math' And [student]='Austin',[score])))

Thanks in advance for looking at this.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:28
Joined
Aug 30, 2003
Messages
36,129
You can't refer to the query that way. You can use a DLookup:

=DLookup("English", "qry_austin_log_gpa")
 

weilerdo

Registered User.
Local time
Today, 11:28
Joined
Apr 21, 2005
Messages
109
Thanks Paul, Where would I do the DLookup at. I tried it in the control source and now I am gettinga #Error
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:28
Joined
Aug 30, 2003
Messages
36,129
It should work as the control source. Make sure the query and field names are correct. You can probably eliminate the query and use a DAvg:

=DAvg("score", "tbl_logs", "[subjest]='Math' And [student]='Austin'")
 
Last edited:

weilerdo

Registered User.
Local time
Today, 11:28
Joined
Apr 21, 2005
Messages
109
Paul, You never cease to amaze me. Thanks again
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:28
Joined
Aug 30, 2003
Messages
36,129
Happy to help! Just noticed I missed the closing quotes in the DAvg, which I'll go back and fix.
 

Users who are viewing this thread

Top Bottom