Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21

    Printing ONLY the current page from a form

    Hello!

    I am very new to Access so pardon any incorrect terminology. I am using a form for data entry, and would like to be able to use a button to pull up only the current page being worked on into print preview to then either email or print out only that selected page. Any of the features in the button wizard pull up alll of the pages. I followed the below advice and created reports to be generated based once a data has been saved in the form.

    https://www.accessforums.net/showthread.php?t=56766

    This has the desired effect of pulling up the current page and sending only that page to the printer or email. However, the enter parameter values pops up with this:

    Forms!Form_Name!Unique_Identifier

    I know all I need to do is enter the unique identifier, which in this case is the order ID. Other users however will just be confused by this, due to the wording, and there is unnecessary room for typos. Is there any way to get the desired effect without needing to enter any parameters?

    I have just started dabbling in the event procedure feature by copying and editing example codes until it works, which so far it has not. Same with macros. If anyone has any examples they are willing to share that would be so helpful. This is the last piece to the database I am working on.



    Thank you!

  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,521
    This is where you're heading:

    https://www.baldyweb.com/wherecondition.htm

    If you're getting a parameter prompt, something is spelled wrong in "Forms!Form_Name!Unique_Identifier". It should to be the name of a control (textbox, etc).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    When I follow those instructions I get an error message:

    The expression on click you entered as the event property setting produced the following error: Invalid outside procedure.
    The expression may not result in the name of a macro, the name of a user- define function, or [Event Procedure]
    There may have been an error evaluating the function, event or Macro

    Maybe I entered it in wrong?

    EX: DoCmd.OpenForm "SecondFormName", , , "FieldName = '" & Me.ControlName & "'"

    Mine: DoCmd.OpenForm "My_FormName", , , "Unique_Identifer = '" & Me.Unique_Identifier & "'"

    As I said I am super new at this, just been using Google and YouTube this past month to try to create an updated database. I am sure there are some common coding terms and words that if I knew, this would be much easier. I am never sure if something needs to be changed to a name of something within my database, or if it is a standard command code.

    Thank you again!

    ** Now I can't even get it back to working with the pop up LOL **

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Numerics need no surrounding characters.
    Dates need # and in yyyy-mm-dd or mm/dd/yyyy
    Quotes need ' unless a ' is in the value, then triple "
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  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,521
    Is your form actually named My_FormName? I would assume not. Also, what is the data type of your unique identifier?

    Further, I thought you were trying to open/print a report? The same syntax works with OpenReport.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Sorry I am having some trouble understanding.
    If my Order_ID data type is a auto number, then should I be following the numeric format? Or is the coding based on the name of the field?

    And for quotes are you saying it should be like this? :

    DoCmd.OpenForm 'My_FormName', , , 'Unique_Identifer = '' & Me.Unique_Identifier & '''



  7. #7
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    No it is not, I just thought for the sake of an easily understandable example that would be best to use lol.

    both the form and generated report are named PickUp_BOL should I have them with different names? The unique identifier is Order_ID

    I am trying to open and print one page, I am using the form as data entry, and if it can open and print from there that is great, but I have found it seemed I would need to print it from a report? Not sure what is best practice.

    Thank you!

  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,521
    More like:

    DoCmd.OpenForm 'PickUp_BOL', , , "Unique_Identifer = " & Me.Unique_Identifier

    Presuming
    Unique_Identifer is a numeric data type. It is the data type of the field specified in the wherecondition that determines the need for delimiters.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by HK123 View Post
    No it is not, I just thought for the sake of an easily understandable example that would be best to use lol.

    both the form and generated report are named PickUp_BOL should I have them with different names? The unique identifier is Order_ID

    I am trying to open and print one page, I am using the form as data entry, and if it can open and print from there that is great, but I have found it seemed I would need to print it from a report? Not sure what is best practice.

    Thank you!
    The number of people that do that annoys me.
    Show what you are trying to use.

    Most of the the time the NOT copy and paste option misses something out.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I've been watching and figure I'll have to ask because no one has mentioned that forms are not for printing. You can, but the results are often unsatisfactory?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  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,521
    Quote Originally Posted by Micron View Post
    I've been watching and figure I'll have to ask because no one has mentioned that forms are not for printing. You can, but the results are often unsatisfactory?
    The OP's link is about using OpenReport, and I did mention a report in post 5. I assume the OpenForm came from my link regarding wherecondition syntax, and was for testing. That said, I get burned a lot when I assume, so...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Upon review and following the links I am totally lost. OP does state that the terminology might be messed up and perhaps that is where he/she should start over. If the distinction between reports/pages/forms is not clear, perhaps that has to be straightened out lest we dance around the issue. Reports have pages, forms do not. Reports do not provide a means of data entry. In design view, which one you are working with is quite obvious by looking at the ribbon and/or property sheet for the object.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Good afternoon all,
    Sorry for the delayed response/confusion and happy holidays to anyone celebrating.
    I will clarify as much as I can here to try to clear up the confusion. I made a form for data entry, and have a report generated to show the data I need printed (As I discovered is needed for formats to show correctly). I would like to be able to get one page only pulled up into the print preview screen and either be printed or emailed out without the other thousands of pages.

    Originally I was trying to print from the form until I realized the aspect of needing to print from a report. So I may have been looking into incorrect solutions for what I needed.

    If I want to print from my report named PickUp_BOL (my form and report have the same name, is this an issue?) and the basis of the unique identifier/primary key would be
    Order_ID.

    Please let me know if there is anything else you need me to clear up, and thank you all so much for trying to help me out!

  14. #14
    Salty Mariner is offline Intermediate
    Windows 11 Access 2021
    Join Date
    Dec 2023
    Location
    Corpus Christi, TX
    Posts
    69
    Quote Originally Posted by HK123 View Post
    Good afternoon all,
    Sorry for the delayed response/confusion and happy holidays to anyone celebrating.
    I will clarify as much as I can here to try to clear up the confusion. I made a form for data entry, and have a report generated to show the data I need printed (As I discovered is needed for formats to show correctly). I would like to be able to get one page only pulled up into the print preview screen and either be printed or emailed out without the other thousands of pages.

    Originally I was trying to print from the form until I realized the aspect of needing to print from a report. So I may have been looking into incorrect solutions for what I needed.

    If I want to print from my report named PickUp_BOL (my form and report have the same name, is this an issue?) and the basis of the unique identifier/primary key would be
    Order_ID.

    Please let me know if there is anything else you need me to clear up, and thank you all so much for trying to help me out!
    Sounds like you have a couple of options here depending on what you are trying to accomplish.

    1. If you only want to email the first page then you can print to PDF and only print the first page.

    2. You can use the query for your report to limit the recordset to data that will fit on one page. Not knowing what your data looks like It's hard to say how to do this whether through grouping, filtering, criteria or a combination. That is kind of up to you depending on what information you are trying to display. You might want to make a copy of your reports recordset and then play around with these until you condense your recordset into something close to what you are looking to achieve, then put it back into your report. I often do this... making a copy so I can experiment on it without messing up what I have already created.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can apparently have a form and report with the same name, but I wouldn't do it. I prefix my objects anyway, so I'd have frmPickUp_BOL and rptPickUp_BOL Try

    DoCmd.OpenReport "PickUp_BOL", acViewPreview, , "Order_ID = " & Me.Order_ID
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Printing a form and making it fit on one page
    By Glenn_Suggs in forum Forms
    Replies: 3
    Last Post: 10-16-2018, 03:54 PM
  2. Replies: 3
    Last Post: 05-11-2015, 12:35 PM
  3. Replies: 4
    Last Post: 02-17-2015, 06:49 AM
  4. Replies: 5
    Last Post: 08-20-2014, 12:37 PM
  5. Replies: 1
    Last Post: 03-05-2013, 06:38 PM

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