gakiss2
Registered User.
- Local time
- Today, 15:41
- Joined
- Nov 21, 2018
- Messages
- 168
I have some code which sets begin date (BegDate) and end date (EndDate). I have a query (qryOutput) which filters properly however I don't filter on the field create_date (yet?). I want to use BegDate and EndDate as the condition to filter create_date. Later there is a command to export the results of the query to an Excel sheet and it works calling qryOutput as its source. I want to be able to have the query filter out results that are not between (and including) BegDate and EndDate. I tried to use the variables (BegDate, EndDate) in the Query Design grid but that didn't work. At least I don't know how, it just thinks they are text and says I have the wrong format which should be a date. THANK YOU
Private Sub CmdNewExport_Click()
Dim datestring As Date
Dim BegDate, EndDate As Date
Dim SelQry As String
datestring = MonthName(Month(Date - 28)) & " " & Year(Date - 28)
datestring = InputBox("Please Enter Alternate Date if needed", , datestring)
BegDate = Month(datestring) & "/" & "1" & "/" & Year(datestring)
EndDate = DateSerial(Year(datestring), Month(datestring) + 1, 1) - 1
' MsgBox BegDate & " " & EndDate
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qryOutput", "C:\Users\gkissick\Desktop\u.xlsx"
End Sub
To clarify. this code 'works', I just haven't figured out how to filter down to the dates I want (between BegDate and EndDate.
Thanks in advance
Private Sub CmdNewExport_Click()
Dim datestring As Date
Dim BegDate, EndDate As Date
Dim SelQry As String
datestring = MonthName(Month(Date - 28)) & " " & Year(Date - 28)
datestring = InputBox("Please Enter Alternate Date if needed", , datestring)
BegDate = Month(datestring) & "/" & "1" & "/" & Year(datestring)
EndDate = DateSerial(Year(datestring), Month(datestring) + 1, 1) - 1
' MsgBox BegDate & " " & EndDate
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "qryOutput", "C:\Users\gkissick\Desktop\u.xlsx"
End Sub
To clarify. this code 'works', I just haven't figured out how to filter down to the dates I want (between BegDate and EndDate.
Thanks in advance