Can't find name in expression

T

Tony Williams

I am creating a query which is based on a table (tblmaintabs) and another
query (qryprevqtr) with a join. I have a field which comes from the query
qryprevqtr called txtprevqtr which is an expression calculated in the query.
I am using that field in an expression in my second query which involves a
DLookup function but I get a message that says Access can't find the name
txtprevqtr which I've entered in the expression. How come? If I run the
query without the second expression the field txtprevqtr is listed.
Any help would be appreciated
Thanks
Tony
 
M

[MVP] S.Clark

Maybe at the time the Dlookup() fires, the field has not been created??
Post the SQL to both queries.
 
T

Tony Williams

Thanks Steve
Here is the SQL for the first query
SELECT tblmaintabs.txtMonthlabel, DateAdd("m",-3,[txtmonthlabel]) AS
txtprevqtr
FROM tblmaintabs
GROUP BY tblmaintabs.txtMonthlabel
HAVING (((tblmaintabs.txtMonthlabel) Between #12/1/2004# And #3/1/2005#));

and here is the SQL for the second query
SELECT tblmaintabs.txtMonthlabel, qryprevqtr.txtprevqtr,
tblmaintabs.txtCompany, tblmaintabs.txtDomfacsoleqtr,
tblmaintabs.txtDomfacsoleqtr, DLookUp("[txtDomfacsoleqtr]","[tblmaintabs]","
[txtMonthlabel] = [txtprevqtr]") AS prevqtr
FROM qryprevqtr INNER JOIN tblmaintabs ON qryprevqtr.txtMonthlabel =
tblmaintabs.txtMonthlabel
GROUP BY tblmaintabs.txtMonthlabel, qryprevqtr.txtprevqtr,
tblmaintabs.txtCompany, tblmaintabs.txtDomfacsoleqtr,
tblmaintabs.txtDomfacsoleqtr
HAVING (((tblmaintabs.txtDomfacsoleqtr)>0));

Hope you can help here I've been at this for 4 days now
Thanks again
Tony
 
Top