Page 2 of 2 FirstFirst 12
Results 16 to 28 of 28
  1. #16
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Still not 100% clear. It would be one page because all the records needed (e.g. for a particular entity) fit on one page? Or it might be 3 pages for 1 entity but you only want to print one page? In the former case it should be simple enough to restrict the records by either adjusting the query as noted, or simply filter the report. Something on the form would provide the filter value but what that is is not clear. Perhaps the id of the current record.



    If it is the latter situation I think you will need to specify a value for the pages to print option. IIRC, that can be provided via code but it is probably simpler to open the Windows print dialog and set your option(s) there.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #17
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    I received the error "Compile error: Invalid outside procedure" I put the code you provided into event procedure of the button on my report. Am I putting in the right place or should it be going on the form? BTW thanks again!

  3. #18
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Behind the appropriate event on the form:

    https://baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Yes, I created a button on my form and did those exact steps shown in your link.
    (I also followed your advice and renamed the Report and Form so they are now, RptPickUp_BOL and FrmPickUp_BOL)

    While in FrmPickUp_BOL I created the button, and went to the event procedure and entered this code, the button label is command 71.

    Private Sub Command71_Click()
    DoCmd.OpenReport "RptPickUp_BOL", , , "Order_ID = '" & Me.ControlName & "Order_ID"
    End Sub

    Now, the error is reading:
    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-defined function, or event [Event Prodecure]
    * There may have been an error evaluating the function, event, or macro


    I am really lost lol. I have been able to figure out all of the other intricacies of my database after searching around for awhile with no previous experience doing anything like this.. but with this one button I am totally stuck!

  5. #20
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Each record would be one page, as the data entry form is formatted that all of the information needed per order is on one page. Each order would need to be sent individually. I tried messing around in the macro settings to create a filter with using the Order_ID which is the primary key for all the orders.. but I could not get it to work... as I just entered Order_ID in the filter section but that was probably not the correct method.

  6. #21
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try the exact syntax I gave you in post 15, changing only the report name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #22
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Code:
    "Order_ID = '" & Me.ControlName & "Order_ID"
    That is not what you were shown in post 15?
    Code:
    "Order_ID = " & Me.Order_ID
    and if Order_ID in the table is a number like 123, it will never equal the concatenation of whatever is in that control plus 123.
    I think you're at the point where you ought to post a zipped db copy to cut to the chase. There is a utility in the forums for randomizing personal data if need be, but it's probably of no use if you use real data as your primary keys (unless you have set up cascading edits in your table relationships).
    Last edited by Micron; 12-29-2023 at 10:44 AM. Reason: correction
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #23
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Sorry, I did try that, I forgot I had been messing with it again before I posted. I did not realize it was not the code you had provided.

    I tried the code: DoCmd.OpenReport "RptPickUp_BOL", acViewPreview, , "Order_ID = " & Me.Order_ID

    My Order_ID is the primary key so, an auto generated number for the table the form is based on. Should I change the filter to something we fill in, like a PO#, which would be unique but not a primary key auto generated number.

  9. #24
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    I will look into trying this, but we do use the data in the primary key so I am not sure I am going to be able to.

  10. #25
    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 HK123 View Post
    Sorry, I did try that, I forgot I had been messing with it again before I posted. I did not realize it was not the code you had provided.

    I tried the code: DoCmd.OpenReport "RptPickUp_BOL", acViewPreview, , "Order_ID = " & Me.Order_ID
    And what happened? Make sure the report doesn't have some other criteria that would clash with this. It should return all records if you open it from the navigation pane.

    I agree this will be a lot easier with a copy of the db. Normally this is a pretty simple bit of code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #26
    HK123 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2023
    Posts
    21
    Update.


    I surrendered to just printing from the form. I had to edit the formatting quite a bit but I was able to do so. I was able to use the button wizard and used the Record commands options for printing a record. I went into the event tab and it is an embedded macro with the following commands:


    RunMenuCommand
    Command SelectRecord
    RunMenuCommand
    Command PrintSelection


    I am 90% sure I already tried this before and it did not work, but I may have added page breaks to the form between trying.


    Its not perfect, as it will have to get saved as a PDF to a file as opposed to just emailing the PDF for sending them.. but it is what it is for now I am on a one man mission for automation and limited time lol. When I have more time I will look into doing it properly, to avoid that extra step. Thank you all for the help and support!

  12. #27
    Salty Mariner is offline Intermediate
    Windows 11 Access 2021
    Join Date
    Dec 2023
    Location
    Corpus Christi, TX
    Posts
    69
    Not trying to be critical because like you I am 100% self-taught and still have an awful lot to learn. I fried a lot of brain cells trying to figure out how to make things work when I was just getting started. In the end though it was actually time well spent because I can assure you that the only way you are going to learn something like Access or another programming language is to dive in and make mistakes (lots of them). It's all part of the learning process. What you are trying to accomplish here amounts to building-block foundational knowledge that you will need moving forward. If you storm ahead and just start creating stuff without mastering the basics you are on a path that will result in even more frustration. My suggestion is to slow down learn the basics and create things that are doable for your current skill level. You will find it far more rewarding in the end. Think about it...When your automation crusade results in an app that is buggy your co-workers will quickly become frustrated when you don't even understand how to fix what you just built. I've been there before and I'm trying to give you a lesson that I learned the hard way. Remember that most of the time you are building something for others to use. Your reputation will suffer if you give them something not ready for prime time. I really wish I had somebody tell me this when I was starting out. My ego was pretty big. I've since been humbled.

  13. #28
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    When I have more time I will look into doing it properly, to avoid that extra step.
    That will unlikely happen if you do not do it now.
    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

Page 2 of 2 FirstFirst 12
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