Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    control button to move through dates

    Hi Guys



    I have a report "rptIncome" built on a query called "qryIncome" that lists all income for this month based in "income date"

    this works really well, but only shows the month we are currently on, in this case December, i am doing this by getting the number of the month "12" for December

    i would like to have a button on my report, that when clicked goes back to last month, i would then re-query the form to show the income based on last month

    i can do this, but im completely stuck on how to go back through more than 1 month

    currently i cant go back passed November Month 11

    the code i have on my button currently is

    Code:
    Private Sub BackButton_Click()
     
    Dim ThisMonth As Integer
    ThisMonth = Month(Date) - 1
    Me.MonthNumberTXTBox = ThisMonth
    Me.Requery
    
    End Sub
    How can i move further back than 1 month, i realise that my code will only go back one month but i have been scratching my head over this and i cant seem to figure it out

    when i get my head around this, the next this i would like to do is have a button that goes forward a month each time

    is this possible?

    Many thanks

    Steve

  2. #2
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi All

    blimey i have been looking at this nearly all day, as soon as i posted i realised how i could do it
    i have used this code and it appears to do what i want

    Code:
    Private Sub BackButton_Click()
     
    Dim ThisMonth As Integer
    If Me.MonthNumberTXTBox = 1 Then
    Me.BackButton.Enabled = False
    Exit Sub
    Else
    ThisMonth = Me.MonthNumberTXTBox - 1 'Month(Date) - 1
    Me.MonthNumberTXTBox = ThisMonth
    Me.Requery
    End If
    
    End Sub


    i can put this on the forward button and change this ThisMonth = Me.MonthNumberTXTBox - 1 to ThisMonth = Me.MonthNumberTXTBox + 1
    and disable the forward button when the month gets to 12

    i think i have cracked it
    Steve

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Outstanding! Thanks for posting back with your success and solution.

    I marked this thread as *Solved* for you, using the *Thread Tools* at the top of the thread.
    https://www.accessforums.net/showthread.php?t=1828

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

Similar Threads

  1. Right click event - move button not working ?
    By Lukael in forum Programming
    Replies: 2
    Last Post: 02-08-2016, 11:48 AM
  2. Runtime error 2110, cannot move focus to control
    By sanderson in forum Programming
    Replies: 7
    Last Post: 11-17-2015, 08:00 AM
  3. Move a command button?
    By 82280zx in forum Forms
    Replies: 2
    Last Post: 06-16-2014, 04:40 PM
  4. Replies: 3
    Last Post: 03-11-2014, 12:12 AM
  5. Replies: 4
    Last Post: 02-09-2013, 09:26 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