Query not picking up current record

pretoria

Registered User.
Local time
Today, 08:20
Joined
Jul 23, 2005
Messages
30
Hello,

Can anybody see what I'm doing wrong here. I have the following query

SELECT Contacts.Cust_FK, Contacts.ContactNr, Contacts.FirstLastName
FROM Contacts
WHERE (Forms.ComLogDetail.Cust_FK=Contacts.Cust_FK)
ORDER BY Contacts.ContactNr;


The "Forms.ComLogDetail.Cust_FK" part should render the current record in the form ComLogDetail but its not. Any ideas?? I'm an amateur programmer so my apolgies if the solution is all too simple.
 
forgot to tell

... if I run the query I get a parameter value popup. When I enter a value it works. So I know the query is working propery except for the above part.
 
SELECT Contacts.Cust_FK, Contacts.ContactNr, Contacts.FirstLastName
FROM Contacts
WHERE Contacts.Cust_FK = Forms!ComLogDetail!Cust_FK
ORDER BY Contacts.ContactNr;

You were using "dots" where you should have been using "bangs".
Also, make sure that the current record has been saved prior to running this query.

DoCmd.RunCommand acCmdSaveRecord
will save the current record.
 
Subforms?

SELECT Contacts.Cust_FK, Contacts.ContactNr, Contacts.FirstLastName
FROM Contacts
WHERE Contacts.Cust_FK = Forms!ComLogDetail!Cust_FK
ORDER BY Contacts.ContactNr;

You were using "dots" where you should have been using "bangs".
Also, make sure that the current record has been saved prior to running this query.

This works when I am at the top level of the form, but not in a query in a subform. Is there anyway to do this for immediate queries in subforms? I am trying to limit the list that returns for a combobox based on another field in the same record.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom