By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

Report underlying query

100+
P: 121
Hi

I have a report with an underlying query. The criteria in the query points to three different controls on a form. The user has to select client name, start date and end date. I want to be able to let the user select just the client name, and not the start and end dates, then run the report, as well as selecting client name, start and end date. Is this possible?

Regards Phill
Expand|Select|Wrap|Line Numbers
  1. SELECT T_ClientDetails.ClientID AS T_ClientDetails_ClientID, T_ActiveSession.SessionID, T_ActiveSession.ClientID AS T_Session_ClientID, T_ClientDetails.FirstName, T_ClientDetails.LastName, T_ClientDetails.Title, T_ClientDetails.OrganizationName, T_ActiveSession.ProjID, T_ArtistProj.ProjBandName, T_Studio.StudioName, T_Studio.StudioDesc, T_ActiveSession.StartDate, T_ActiveSession.EndDate, T_ActiveSession.StartTime, T_ActiveSession.EndTime, T_SessRate.Rate, T_ActiveSession.SessComplete, DateDiff("n",[starttime],[endtime]) AS DateDiffEXP, [datediffexp]\60 & Format([datediffexp] Mod 60,"\:00") AS DateDiffFormatExp, [Rate]/60*[datediffexp] AS TotalExVATExp, Round([vatvalue]/100*[TotalExVATExp],2) AS VATExpr, [TotalExVATExp]+[VATExpr] AS TotalIncVATExpr, T_VATValue.VATValue, T_ArtistProj.ProjectDesc
  2. FROM T_VATValue, T_ClientDetails INNER JOIN (T_Studio INNER JOIN (T_SessRate INNER JOIN (T_ArtistProj INNER JOIN T_ActiveSession ON T_ArtistProj.ProjBandID = T_ActiveSession.ProjID) ON T_SessRate.SessRateID = T_ActiveSession.SessRateID) ON T_Studio.StudioID = T_ActiveSession.StudioID) ON T_ClientDetails.ClientID = T_ActiveSession.ClientID
  3. GROUP BY T_ClientDetails.ClientID, T_ActiveSession.SessionID, T_ActiveSession.ClientID, T_ClientDetails.FirstName, T_ClientDetails.LastName, T_ClientDetails.Title, T_ClientDetails.OrganizationName, T_ActiveSession.ProjID, T_ArtistProj.ProjBandName, T_Studio.StudioName, T_Studio.StudioDesc, T_ActiveSession.StartDate, T_ActiveSession.EndDate, T_ActiveSession.StartTime, T_ActiveSession.EndTime, T_SessRate.Rate, T_ActiveSession.SessComplete, T_VATValue.VATValue, T_ArtistProj.ProjectDesc
  4. HAVING (((T_ClientDetails.ClientID) Like [Forms]![F_ClientSessDRange].[combo7]) AND ((T_ActiveSession.StartDate)>=[forms]![f_ClientSessDrange]![BeginDate] And (T_ActiveSession.StartDate)<=[forms]![f_ClientSessDrange]![EndDate]) AND ((T_ActiveSession.SessComplete)=True));
  5.  
Feb 26 '09 #1
Share this Question
Share on Google+
6 Replies


100+
P: 121
Also is there a way to view all the clients so in the combo box there would be a record that says All Clients

Cheers Phill
Feb 26 '09 #2

NeoPa
Expert Mod 15k+
P: 31,419
Try replacing line #4 with :
Expand|Select|Wrap|Line Numbers
  1. HAVING ((T_ClientDetails.ClientID Like [Forms]![F_ClientSessDRange].[combo7])
  2.    AND  (T_ActiveSession.StartDate Between Nz([Forms]![f_ClientSessDrange]![BeginDate],#1/1/1900#)
  3.                                    And     Nz([Forms]![f_ClientSessDrange]![EndDate],#12/31/9999#)
  4.    AND  (T_ActiveSession.SessComplete))
Feb 26 '09 #3

NeoPa
Expert Mod 15k+
P: 31,419
Alternatively, it's possible to open a Report, specifying a WhereCondition parameter that filters it on-the-fly.

For the record, I suggest you clear the date and client filtering from the query itself, and build a string dynamically in your code.
Feb 26 '09 #4

100+
P: 121
Thanks Neopa great help
Feb 26 '09 #5

NeoPa
Expert Mod 15k+
P: 31,419
@phill86
Yes.

If you specify the RecordSource of the ComboBox as having an extra column which is set to be the default returned value of the control, but is not visible, You would need to ensure the value matching the "All Clients" entry is set to "*".
Feb 26 '09 #6

100+
P: 675
Also is there a way to view all the clients so in the combo box there would be a record that says All Clients
I'm assuming the ComboBox has 2 columns, ID and Name, that ID is a key. and you mean row, not record, in "...be a record that...". The following SQL statement illustrates how such a combo might be filled. The WHERE clause is for illustration, and might not be needed.
Expand|Select|Wrap|Line Numbers
  1. SELECT tClients.Key AS ID, tClients.Name AS Name
  2. FROM tClients
  3. WHERE (((tClients.Key)<10)) UNION SELECT -1 AS ID, "<<Select All>>" AS Name FROM tClients ORDER BY Name;
Test for combobox.value = -1 to see if "<<Select All>>" chosen.
Feb 26 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.