Results 1 to 10 of 10
  1. #1
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118

    Setting Height and Width with VBA

    Good morning, everyone. I'm trying to use VBA to set the height and width of my reports. I've tried 3 different things in the Report Load event, and none have worked. This got me an error message:



    Me.InsideWidth = 8 * 1440
    Me.InsideHeight = 6.2 * 1440

    These didn't give me an error message, but they didn't work either:

    Me.Width = 8 * 1440
    Me.Detail.Height = 6.2 * 1440

    and...

    DoCmd.MoveSize 1100, 550, 8, 6.2

    Any idea what I'm doing wrong here? Thanks for your help.

    Matthew

  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,652
    I'm curious why you'd set them in code rather than design view, but you might try the open event rather than the load event, which may be too late.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Thanks very much for the reply. I should actually clarify that I want to set the size of the window, not the report itself.

    Unfortunately, putting the code in the the Open event did not work either. Do you have any other ideas, perhaps?

  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,652
    Oh, then probably no code in the report. You can try MoveSize in the code that opens the report, though I've never tried it with a report. I usually maximize reports. If you size the window once it's open, will it hold that size the next time it opens? Forms do that, haven't checked with reports.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    By the way, what is the setting in File/Access Options/Current Database for document window options? It should be overlapping windows instead of tabbed documents I suspect.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Thanks for the reply. Unfortunately, I tried using MoveSize in the Open event, and it did not work.

    And if I resize a report window manually, that size will not hold next time I open it.

    And you are correct, it is overlapping windows, not tabbed.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I mentioned the code opening the report, not the report's open event.

    DoCmd.OpenReport...
    DoCmd.MoveSize...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Oh, and MoveSize uses twips, not inches.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    MatthewR is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2015
    Posts
    118
    Ah, excellent. That works. Thank you very much.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    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. Image .jpg get original height and width using vba
    By WhiteBearMike in forum Programming
    Replies: 1
    Last Post: 05-27-2014, 04:47 PM
  2. Replies: 9
    Last Post: 02-07-2014, 07:42 PM
  3. Setting Report Height In Code
    By ccordner in forum Reports
    Replies: 1
    Last Post: 12-07-2012, 10:26 PM
  4. Replies: 4
    Last Post: 09-15-2012, 07:31 PM
  5. Use fixed height and width for the Access window
    By AndrewAfresh in forum Access
    Replies: 3
    Last Post: 07-05-2006, 09:20 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