Hi all,
I have some code which counts records that match a selection from a drop down list. This all works fine, my problem is that I would like to also narrow down the count to data from a specific month.
Here is the code I have:
(StrQLeadSource & LCtLeadSourceUp are variables (string & long respectively) and CBoxLeadSourceLS is the combobox which forms the drop down list.
This code goes through each item of the list and updates a separate table with the quantities of each one.)
and attached is a screen shot of the table with sample data in.
I would like the code to take the current month and reduce by 1 (to get last month's data) then search for (& count) all records that match my current search plus the month figure generated (this month -1).
I have been able to get the data for today using:
but I can't seem to separate the month part of the date field.
Any help would be greatly appreciated. If you need any more info please ask.
Thanks,
Gav
I have some code which counts records that match a selection from a drop down list. This all works fine, my problem is that I would like to also narrow down the count to data from a specific month.
Here is the code I have:
Code:
For i = 1 To 38
StrQLeadSource = CBoxLeadSourceLS.ItemData(i)
CBoxLeadSourceLS.Value = StrQLeadSource
LCtLeadSourceUp = DCount("[Lead Source]", "Leads", "[Lead Source] = CBoxLeadSourceLS.Value")
DoCmd.SetWarnings False
Call DoSQL
DoCmd.SetWarnings True
Next i
End Sub
Public Sub DoSQL()
Dim SQL As String
SQL = "UPDATE LeadSource " & _
"SET [Quantity] = " & LCtLeadSourceUp & " " & _
"WHERE [ID] = " & i
DoCmd****nSQL SQL
End Sub
This code goes through each item of the list and updates a separate table with the quantities of each one.)
and attached is a screen shot of the table with sample data in.
I would like the code to take the current month and reduce by 1 (to get last month's data) then search for (& count) all records that match my current search plus the month figure generated (this month -1).
I have been able to get the data for today using:
Code:
LCtLeadSourceUp = DCount("[Lead Source] & [Lead Date]", "Leads", "[Lead Source] = CBoxLeadSourceLS.Value" & " " & "AND [Lead Date] = #" & Now & "#")
Any help would be greatly appreciated. If you need any more info please ask.
Thanks,
Gav