Then code must use QueryDefs to modify the query SQL.
I do not understand 'lose the original filter'.
Users should not even see much less work directly with tables and queries.
Then code must use QueryDefs to modify the query SQL.
I do not understand 'lose the original filter'.
Users should not even see much less work directly with tables and queries.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
There is a button named Warning on the form--- what is that for?
I'm having some difficulty understanding the underlying issue to be solved. But I also do not follow the design on the form --the buttons (btnOffCal and Warning occupy the same space (or darn near). There is no btnCal. You are using formatted Dates, which imply strings, to do your selection. And the button runs a query --it isn't used as a recordsource for form or report.
I don't know if any of this is helpful, but those are some observations.
I think this is what I will have to do...
I'm not sure how to go about doing it.
And I'll be using this query as the recordsource of a form. I'm trying to get the query worked out first.
If you go into design and move the butons around, you will see there are three buttons, but this is besides the issue lol...There is a button named Warning on the form--- what is that for?
I'm having some difficulty understanding the underlying issue to be solved. But I also do not follow the design on the form --the buttons (btnOffCal and Warning occupy the same space (or darn near). There is no btnCal. You are using formatted Dates, which imply strings, to do your selection. And the button runs a query --it isn't used as a recordsource for form or report.
I don't know if any of this is helpful, but those are some observations.
I explained my problem the best I could in post 14. There is simply no further explanation to provide...
If you are using query as record source for a form, what is the issue? Apply filter criteria to form as already suggested.
What 'other filters'? Are they dynamic?
Building and modifying queries with QueryDefs is not simple.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
When applying a filter, if you toggle the filter you lose all previous filters applied.
They are not complicated, and could easily be set by the user, however I'm trying to eliminate this step.
I need the original "Calendar" or "Off Calendar" filter to stay. Being that the dates are either "12/31"(Calendar) or "<> 12/31"(Off Calendar).
Yes I moved the buttons in design view I see all three. But now the mystery is why did the vba code fail on the reference to btnCal??
Anyway enough time spent on this and June has given some ideas.
Good luck.
I still don't understand issue. If you want data filtered by the Calendar/CalendarOff option, include that in the VBA structure.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
No. I have used QueryDefs once.
In this example I resorted to deleting and recreating query object because could not figure out how to change just the WHERE clause. Now that I think more about it, don't really see how QueryDefs can serve your needs any better than constructing filter and applying to form or report.
Private Sub btnExcel_Click()
Dim qdfUser As DAO.QueryDef
CurrentDb.QueryDefs.Delete ("UserQuery")
Set qdfUser = CurrentDb.CreateQueryDef("UserQuery", Me.tbxFilter)
DoCmd.OpenQuery "UserQuery", , acReadOnly
DoCmd.RunCommand acCmdExportExcel
End Sub
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.