Tezcatlipoca
Registered User.
- Local time
- Today, 20:13
- Joined
- Mar 13, 2003
- Messages
- 246
Take a look a the attached database, which is a vastly cut-down version of the project I'm currently working on.
I have a form, frmReports. On it, I have a listbox, AdvisorList (containing a list of all those names that appear under UserName in the tblEmployees); two date fields, txtStartDate and txtEndDate; and an unbound textbox, Results.
Currently, I can easily use DCount functions in unbound text boxes to tot up the total records according to the dates. for example, in the proper project, selecting an advisor shows the total number of calls taken by that advisor in an unbound textbox that contains the folloiwng ControlSource code:
What I now want to do is implement the ability for a user to select any advisor they like, and any dates they like, and have the textbox Results return the number of individual members helped by that advisor between the dates given.
For example, in the table. Advisor 'Don Quixote' has logged two calls for member 057426 (on the 8th and 11th of November) and two for member 029544 (on the 11th and the 15th). This is four calls in total, but it only relates to 2 distinct members.
So I'm trying to do is create a query that will check the UserName from tblLogs against AdvisorList, the CallLog against the txtStartDate and txtEndDate, ignore the records in tblLogs that have a blank UserName, and, if all criteria match, will return the number of distinct MemberNumber records.
So, from the 1st of November to the 20th of November, Don Quixote has helped two distinct members. However, if I reset the dates to 12th and 20th of November, he has helped only one distinct member (albeit with 2 calls).
I have a form, frmReports. On it, I have a listbox, AdvisorList (containing a list of all those names that appear under UserName in the tblEmployees); two date fields, txtStartDate and txtEndDate; and an unbound textbox, Results.
Currently, I can easily use DCount functions in unbound text boxes to tot up the total records according to the dates. for example, in the proper project, selecting an advisor shows the total number of calls taken by that advisor in an unbound textbox that contains the folloiwng ControlSource code:
Code:
=DCount("MemberNumber","tblLogs","[UserName] = '" & [AdvisorList] & "' AND [CallLog] BETWEEN #" & Format([Forms]![frmReports]![txtStartDate],"mm/dd/yy") & "# AND #" & Format([Forms]![frmReports]![txtEndDate],"mm/dd/yy") & "#")
What I now want to do is implement the ability for a user to select any advisor they like, and any dates they like, and have the textbox Results return the number of individual members helped by that advisor between the dates given.
For example, in the table. Advisor 'Don Quixote' has logged two calls for member 057426 (on the 8th and 11th of November) and two for member 029544 (on the 11th and the 15th). This is four calls in total, but it only relates to 2 distinct members.
So I'm trying to do is create a query that will check the UserName from tblLogs against AdvisorList, the CallLog against the txtStartDate and txtEndDate, ignore the records in tblLogs that have a blank UserName, and, if all criteria match, will return the number of distinct MemberNumber records.
So, from the 1st of November to the 20th of November, Don Quixote has helped two distinct members. However, if I reset the dates to 12th and 20th of November, he has helped only one distinct member (albeit with 2 calls).