Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,965
    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.

  2. #17
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    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.

  3. #18
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Quote Originally Posted by June7 View Post
    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.
    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.

  4. #19
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Quote Originally Posted by orange View Post
    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.
    If you go into design and move the butons around, you will see there are three buttons, but this is besides the issue lol...

    I explained my problem the best I could in post 14. There is simply no further explanation to provide...

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,965
    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.

  6. #21
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    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).

  7. #22
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    Quote Originally Posted by cbende2 View Post
    If you go into design and move the butons around, you will see there are three buttons, but this is besides the issue lol...

    I explained my problem the best I could in post 14. There is simply no further explanation to provide...
    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.

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,965
    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.

  9. #24
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Quote Originally Posted by June7 View Post
    I still don't understand issue. If you want data filtered by the Calendar/CalendarOff option, include that in the VBA structure.
    I guess I will do some research on querydefs then?

    Any good references besides microsoft's examples?

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,965
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query criteria from Combo box
    By cbende2 in forum Access
    Replies: 3
    Last Post: 06-29-2015, 09:06 AM
  2. Form Combo as Query Criteria
    By SteveApa in forum Forms
    Replies: 1
    Last Post: 01-16-2015, 08:21 AM
  3. Combo box in query criteria
    By nittany77 in forum Queries
    Replies: 19
    Last Post: 08-19-2014, 04:02 AM
  4. Combo Box for Query CRITERIA?
    By TUPJK in forum Queries
    Replies: 5
    Last Post: 06-04-2014, 10:43 AM
  5. Combo Boxes Query Criteria help
    By noaccessguru in forum Queries
    Replies: 2
    Last Post: 04-30-2012, 08:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums