Results 1 to 5 of 5
  1. #1
    krag is offline Medium experience
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    71

    How do you use ForceNewPage

    How do we set ForceNewPage property in VBA?
    I tried true / false but not working as expected.
    I tried setting:


    me.Code0Header.ForceNewPage="None" or "Before Section", etc.
    It gives error message.
    Is it a parameter number like 0, 1, 2, 3?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    If you want to assign a value to the property, take a look at that property while in Design View of your Report. Look at the options provided. I believe they are Yes and No. So, pass that as a string value.

    Maybe ...
    ForceNewPage="No"

    Then, determine where to place your VBA. You need to use the correct On Format event. That property will not be available on every Format event.

  3. #3
    krag is offline Medium experience
    Windows 7 32bit Access 2013
    Join Date
    May 2014
    Posts
    71
    Thanks for your suggestion.
    Actually I did that.
    Property options for ForceNewPage are "None", "Before Section", "After Section", and "Before and After Section".
    When I use same as string value, error comes up on that line when run.
    I guess there is some other way to code the options.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I suspect the desire to use VBA is because you want a specific condition to be met before forcing a new page. I think what is happening is Access has already decided this property at the time your code is running. So you will need to determine the event that allows this property to be adjusted. It may be decided during On Open or On Load.

    Are you sure you are using the correct section/group of your report? I would change the property in the property sheet for testing purposes. So, set focus on the Code0Header and then adjust the Force New Page property to something like Before Section. Then see if the report is behaving predictably. Even if this is not the permanent solution.

    After you are sure you have the correct section/group name and you know you want the Header before the Footer or vice versa, identify the correct event to place your VBA. I would start with the On Format event for the section and footer vs. header. Then I would look at moving the code around to different places.

    According to this link at MSDN, it is both read and write.
    https://msdn.microsoft.com/en-us/lib.../ff823096.aspx

    Maybe if assigning the string is not working, you can decipher what the integer value is by setting the property in the property sheet and using the VBA immediate window or the Watch window to determine the integer value. Take a look at this example in the MSDN link.
    Code:
    Dim intGetVal As Integer 
    intGetVal = Reports![Sales By Year].Section(acDetail).ForceNewPage

  5. #5
    krag is offline Medium experience
    Windows 10 Access 2013
    Join Date
    May 2014
    Posts
    71
    Thanks again.
    I got the values as 0 to 3 finally.
    Now I have to figure out where to locate the code.
    I think I can figure it out by trial and error.

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

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