Eljefegeneo
Still trying to learn
- Local time
- Today, 14:26
- Joined
- Jan 10, 2011
- Messages
- 904
I am trying to open up my frmMain with only active clients. I do have a control [Class} which has among several options, "Active". However when I use a macro to open the form with the critera [Class] = "Active, sometimes I get non-active clients. This is because [Class} is updated on the form's OnCurrent event based on another calculated field. But, of course, I have to have a particular record open for the [Class] control to be updated. So I decided to use the DLookup function based on a query that only gives me "Active" clients. The query is:
SELECT tblSales.ClientID, Min(IIf([ContractsEnds]<Date() Or [DateCancelled]<Date(),"Inactive","Active")) AS CustomerStatus
FROM tblSales
GROUP BY tblSales.ClientID;
But, when I used
DoCmd.OpenForm "frmMain", , DLookup("[ClientID]", "qryOnAirActive", '[CustomerStatus] = 'Active'")
I get only one record and it is not active. I've tried all kinds of variations for the criteria with no good results, usually an error message.
The query works fine, I just can't get it to work with the Docmd.OpenForm
Any suggestions?
SELECT tblSales.ClientID, Min(IIf([ContractsEnds]<Date() Or [DateCancelled]<Date(),"Inactive","Active")) AS CustomerStatus
FROM tblSales
GROUP BY tblSales.ClientID;
But, when I used
DoCmd.OpenForm "frmMain", , DLookup("[ClientID]", "qryOnAirActive", '[CustomerStatus] = 'Active'")
I get only one record and it is not active. I've tried all kinds of variations for the criteria with no good results, usually an error message.
The query works fine, I just can't get it to work with the Docmd.OpenForm
Any suggestions?