7 replies
by greg Accepted solution
by jerry~beans&bytes Accepted solution
'cause if you are writing the query in SQL, you could just use a WHERE([target field] Between [Textbox1] And [Textbox2])
Textbox 1 & 2 can be in any handy table.
doesn't restrict you to multiples of 30 days, tho'
by greg Accepted solution
******Begin SQL*****
SELECT Names.FirstName, Names.LastName, Time.Area, Last(Time.Date) AS LastOfDate
FROM (Contact_Interest INNER JOIN [Names] ON Contact_Interest.ContactID = Names.ContactID) INNER JOIN [Time] ON Contact_Interest.ContactID = Time.ContactID
GROUP BY Names.FirstName, Names.LastName, Time.Area, Contact_Interest.ContactID, Contact_Interest.CIBS, Contact_Interest.CIC, Contact_Interest.CIK, Contact_Interest.CITS, Contact_Interest.CISE, Contact_Interest.CICC, Contact_Interest.Mentoring, Contact_Interest.aUX, Contact_Interest.CIADMIN
HAVING (((Time.Area)=[Forms].[Form2].[Combo6]))
WITH OWNERACCESS OPTION;
****End SQL*****
The only area that I need to filter from my first Cbo is the Time.Area AND another Cbo to choose Time.date. When the user chooses 30 days in the combo it returns only those from the last 30 days and so on. Do I need to write a macro, place vba somewhere else?
The OnClick event for the button on the form is:
Private Sub AOSReport_Click()
On Error GoTo Err_AOSReport_Click
Dim stDocName As String
stDocName = "Area Of Service"
DoCmd.OpenReport stDocName, acPreview
Exit_AOSReport_Click:
Exit Sub
Err_AOSReport_Click:
MsgBox Err.Description
Resume Exit_AOSReport_Click
End Sub
If there is any other info you need
by jerry~beans&bytes Accepted solution
is there a reason why you can't create another Cbo ([Forms].[Form2].[Combo7]), and modify your HAVING statement to:
"HAVING ((((Time.Area)=[Forms].[Form2].[Combo6])) AND ((Time.Date)=[Forms].[Form2].[Combo7]))" ??
it works with the WHERE command (i'm in Access 02), so if HAVING doesn't allow you to add the AND statement, you might try using WHERE, and see if A'07 will accept it.
(edit-some more coffee later) actually, your statement might end up something like "WHERE(HAVING((Time.Area)=[Forms].[Form2].[Combo6]) AND HAVING((Time.Date)=[Forms].[Form2].[Combo7]))"
by greg Accepted solution
by jerry~beans&bytes Accepted solution
you could do what i usually do-go back to the basics. change the combo boxes to text boxes (format as Dates), then use a BETWEEN, i.e. "WHERE (([Table1].[Date] Between [Forms].[ReportDatesForm].[Text1] And [Forms].[ReportDatesForm].[Text2]))"
simple, flexible, intuitive. but it doesn't restrict the date range to multiples of 30-day intervals; how important is this restriction to you?
if you are comfortable with VBA, you could define a variable and value it, then use your HAVING on the variable, i guess.
i'm just an accountant who learned SQL so i could do custom reports. the details of such a thing are a little over my head, so i can't be much help if you take that road.
by greg Accepted solution
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending