Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46

    How to change report to page 2 programmatically?

    Hi Experts,



    Anyone know or have any ideas/guidence on how to programmatically change my report to page 2?

    I have search online and tried various VB command to try to touch the report pages with no luck.

    I was looking into .report(index) indexs, or a reports.page property but have not had much luck

    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    Thanks guys!

    Naeem~

  2. #2
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    How to change report to page 2 programmatically?

    You could look into the PAGE(S) Property

    Report.Page property returns current page number.
    Report.Pages property returns total pages in a report.

    You could also use the
    SendKeys "{PGDN}"
    To go down.

    http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

  3. #3
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Thanks Alex.

    I have read that I should (when possible) avoid using sendkeys.. let me see if I can implement your idea into my script..

    any other ideas would be great... im still researching..

  4. #4
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Unfortunaely the SendKeys "{PGDN}" or SendKeys "{PGUP}" does nothing to the report page, even though it appears to be the active form/screen.

    Heres my snipit of script...

    '-----------------------
    Dim CUser As String
    Dim LNumofRecs As Long
    Dim IDNum As String
    Dim PgNum As String
    CUser = Me.Text12
    Udate = Me.Combo2

    LNumofRecs = DCount("LOG_DATE", "tblTIMESHEET", "USER_DATETIME=#" & Udate & "#")
    For I = 1 To LNumofRecs 'iterate through the number of pages in the table - 12_3_13 na
    IDNum = Reports![rptMAINT_LOG]![Text112]
    SendKeys "{PGUP}"
    Next

    '-----------------------

    Man .. this is kicking my butt today.. the thankgiving holiday can set my brain back a few notches.. LoL

    Naeem~

  5. #5
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180
    SendKeys isn't brilliant but I've just tested it on a Report and it does move the page down.

    By Default the Page is going to be at the Top so using SendKeys "{PGUP}" won't move it anywhere.

  6. #6
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Interesting.. may I see how you formated your test code? Thanks.

  7. #7
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180
    Code:
    Private Sub Report_Load()
        SendKeys "{PGDN}"
        'Repeat until it hits where you need it to on the page.
    End Sub

  8. #8
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Interesting.. My test code is currently on a command button.. not on the LOAD event..

    I tried all variations;

    SendKeys "{PGUP}"
    SendKeys "{PGDN}"
    SendKeys "{LEFT}"
    SendKeys "{RIGHT}"

    I had {PGUP} as a test becuase when I validated what page im on programmatically.. is tell me that its looking at the last page first.. either way.. my script is not a happy one.. yet...lol

  9. #9
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Thanks for the idea Alex.. U or Anyone have any other ways to programmatically move to page 2 on a report from a command button? Still researching.. :/

    I may have to change my approach and try a different method. I will create an array to collect and extract teh data requierd rather than iterate thgrough the report pages fields instead.

    Thanks for your help though.. If you still come up with some ideas please post them.. I will still be research best practice for this script I need.

  10. #10
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180
    I've just added a button to my Report
    Code:
    Private Sub cmdMoveDown_Click()
        SendKeys "{PGDN}"
    End Sub
    and whilst in 'Report View' if I click it, it moves.
    Which version of Access are you using?

    - - -
    Would it be possible to find out why you need to go onto Page 2 of the Report, what is on there that you need?
    If the Report is based on a Table/Query why not just loop through that and get the Data you need from there.

  11. #11
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180
    You might want to try:

    http://bytes.com/topic/access/answer...-automatically

    Code:
    Option Compare Database
    Const Interval = 1000 '1000 ms between pages
    
    Private Sub Command0_Click()
    
        DoCmd.OpenReport "REPORTNAME", acPreview
        Me.TimerInterval = Interval
        Me.OnTimer = "[Event Procedure]"
     
    End Sub
     
    Private Sub Form_Timer()
     
        Dim lngPage As Long
     
        On Error GoTo CancelTimer
     
        With Reports!REPORTNAME
     
            On Error GoTo ExitSub 'the next row fails if no report is in focus
            If Screen.ActiveReport.Name = "REPORTNAME" Then
                lngPage = .Page
                SendKeys "{PGDN}", True
                If .Page = lngPage Then GoTo CancelTimer
            End If
            On Error GoTo 0
     
        End With
     
    ExitSub:
        Me.TimerInterval = Interval
        Exit Sub
     
    CancelTimer:
        Me.OnTimer = ""
     
    End Sub
    Amend to go to Page 2.

  12. #12
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Interesting.. thanks Alex.. let me see if I can incorporate something like that.. I will post up what I come up with.. thanks again!

  13. #13
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Ok... may hair has officially started falling out and I dont have many strand left !! LoL... can someone please tell me why this peice of code does not hit the SENDKEYS.. it just continues and endless loop

    The test script below should cycle through the pages, until it reaches all pages and stop.. I need the SENDKEYS to move the active report to the next page, but it seems to just ignore the SENDKEYS and just loop over and over.. cant seem to see what im missing or on the wrong line in place..

    Any help is greatly appericiated! Thanks All!

    '--------------------
    Private Sub Command16_Click()

    Dim lngPage As Long

    DoCmd.OpenReport "rptMAINT_LOG", acViewPreview

    With Reports!rptMAINT_LOG

    Do Until .Page = .Pages

    On Error GoTo ExitSub 'the next row fails if no report is in focus
    If Screen.ActiveReport.Name = "rptMAINT_LOG" Then
    lngPage = .Pages
    SendKeys "{PGDN}", False
    If .Page = lngPage Then GoTo MsgBx
    End If
    Loop

    End With

    MsgBx:
    MsgBox ("Done")
    ExitSub:
    End Sub
    '--------------------

  14. #14
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180
    If you put a Debug.Print "BLAH" after
    Code:
    SendKeys "{PGDN}", False
    does it print anything?

  15. #15
    naeemahmad is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Location
    Riverside, USA
    Posts
    46
    Ok.. with some more testing... apparently SENDKEYS will not work in PRINTPREVIEW.. it will only work in REPORTVIEW and .PAGE(S) only works in REPORTVIEW and not PRINTPREVIEW..

    Now this creates another issue for me.. since I im iterating through the .page(s) propoerty that is only available in PRINTPREVIEW while trying to use SENDKEYS which only works from the REPORTVIEW mode..

    not sure how to approach this now.. no wonder VBA will be dead soon.. LoL..

    I am going to attempt to have them work together and see what happenes now.. wish me luck!

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

Similar Threads

  1. How to change query criteria programmatically
    By fekrinejat in forum Programming
    Replies: 2
    Last Post: 02-04-2013, 05:07 PM
  2. Programmatically change default switchboard at startup?
    By romeo_echo in forum Programming
    Replies: 4
    Last Post: 08-05-2011, 11:45 AM
  3. Replies: 2
    Last Post: 08-29-2010, 01:17 AM
  4. how to change report code page
    By broken_ice in forum Reports
    Replies: 1
    Last Post: 06-27-2010, 02:23 AM
  5. Change Row Background Color Programmatically
    By sales@4bco.com in forum Programming
    Replies: 2
    Last Post: 10-25-2009, 11:17 AM

Tags for this Thread

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