Results 1 to 11 of 11
  1. #1
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17

    Advancing Date with a command button


    Question of curiosity. Is it possible to have command buttons on a form to advance the current recordset filter date back or forwards one day at a time on each click. Would go like if today was the 15th and I clicked it would go to the 16th and then to the 17th for the next click and so on. Just not sure if I should keep looking for a way to do this, so I figured I would ask some experts before putting more time in to this then I already have to no avail.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Sure. If you filter off a textbox:

    Me.TextboxName = Me.TextboxName + 1

    Then apply the filter or whatever
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17
    Thanks Paul, I 'll play around with it tomorrow to see if I can do what you are referring to. I'll let you know if I can do it, and not I'll be asking some more questions.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problem; I have several apps with up/down buttons so users can scroll dates. Welcome to the site by the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17
    Paul,

    Perhaps this is more complex then I can handle. can you point me to an example app so I can break it down and see if I can apply it?
    I can get the text boxes changing on +1 or -1. And then apply the filter to the form filter like such>

    Private Sub CmdPday_Click()

    Me.TxtDayFilter = Me.TxtDayFilter - 1

    Me.Filter = TxtDayFilter

    End Sub



    Thanks

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    The filter line would look like

    Me.Filter = "FieldName = #" & Me.txtDayFilter & "#"
    Me.FilterOn = True
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17
    Paul,

    Just want to thank you again. That certainly cleared it up. I gotta read a good book on VBA, do you have any suggestions? May be VBA for Dummies that might be the ticket for me.
    On another note, once I click on a button to apply a filter for say today. What method would be best to set the text box txtDayFilter back to that date? So that it reflects the current filtered date imposed by another method. I have a few command buttons to set the filter to like this month, last month today. Don't give any code just yet, just point me the right direction so I can try and figure it out. And if I can't I will ask.

  8. #8
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17
    Tried using this and it seems to work alright. what do you think?

    Private Sub CmdLastMonth_GotFocus()
    Me.TxtDayFilter = Me.Sch_date
    End Sub

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I'm not clear what this is trying to accomplish. If this is "to set the text box txtDayFilter back to that date", then that method is fine, presuming Me.Sch_date contains the date you want to go back to.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    rmd62163 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    17
    Could of swore I replied yesterday but I don't see it. Anyhow your assumption is correct. that is what I was trying to accomplish. What did since that was just moved it to the on click event for the button that changes the filter. works the same i suppose, not much different.

    Thanks again Paul.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-13-2012, 01:51 PM
  2. Within form, advancing to next record
    By crowegreg in forum Forms
    Replies: 2
    Last Post: 08-07-2011, 09:18 PM
  3. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  4. Command Button
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 07-05-2010, 08:02 PM
  5. Command button for time & date
    By joet5402 in forum Forms
    Replies: 2
    Last Post: 12-20-2007, 02:59 AM

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