forms reference not working at form level but does at query level?

R

redtux

Hi I am very confused by this issue - here is the SQL

SELECT lk_stages.stage, lk_stages.stage & " -" & [stage_cat] & " - " &
[stage_desc] AS [desc]
FROM lk_stages INNER JOIN tb_progress ON lk_stages.stage = tb_progress.Stage
WHERE
(((tb_progress.complaint_id)=[forms]![fm_client_tracking]![complaint_id]) AND
((Left([lk_stages]![stage],1))=Left([tb_progress]![stage],1)))
GROUP BY lk_stages.stage, lk_stages.stage & " -" & [stage_cat] & " - " &
[stage_desc];


This works if I run from a query(and form is open) - but if I try to run it
from the form I get a prompt for
)=[forms]![fm_client_tracking]![complaint_id] (which is the form)

Any ideas/explanations for this appreciated
 
K

Klatuu

You have a syntax problem. Anything is quotes is taken as literally what is
in the quotes. To use the references, they have to be outside the quotes.

SELECT lk_stages.stage, lk_stages.stage & " -" & [stage_cat] & " - " &
[stage_desc] AS [desc]
FROM lk_stages INNER JOIN tb_progress ON lk_stages.stage = tb_progress.Stage
WHERE
(((tb_progress.complaint_id)= '" &
[forms]![fm_client_tracking]![complaint_id]) & "' AND
((Left([lk_stages]![stage],1))=Left([tb_progress]![stage],1)))
GROUP BY lk_stages.stage, lk_stages.stage & " -" & [stage_cat] & " - " &
[stage_desc];

If tb_progress.complaint_id is a numeric field, leave out the single quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top