Results 1 to 5 of 5
  1. #1
    steveo0707 is offline Novice
    Windows 11 Office 365
    Join Date
    Oct 2023
    Posts
    20

    Search Button and Save Button

    Hello,

    I have a db that tracks nonconformance parts. I have asked a few questions about this in the past, but not sure I have explained very well my level of expertise in VBA. I am very new to VBA and don't quite understand how all the DoCmd.'s work for Access.

    I am trying to accomplish two things:

    I have a search button next to NCMR Number. There was a code in there for the operator to click the button and it would go to a specific record so we could update as needed. somewhere over the past couple of weeks it got deleted.

    So, I need code to allow this to happen.



    The code listed below was previously there from another user. It is the current code to print our NCMR Form. The default Printer is set to Print to PDF so we can save. then the operator clicks control P to print. However, this changes the default printer, and a couple of my operators are not so computer savvy and can't figure out to change the default printer back to print to PDF. I want to create a save button that will save it to a specific drive location. I know this would all be easier if it was a report, however this was already in place, and I plan on transforming this into a report when time allows.

    I am not sure how to modify the code below so I can save the document.

    Using the export to PDF will not work, since it tries to save all 6500 records that are in the form. Is there a way to filter this out? If so, how is this accomplished?


    Code:
    Private Sub PrintButton_Click()On Error GoTo Err_Print_Record_Click
    
    
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.PrintOut acSelection
    
    
    Exit_Print_Record_Click:
        Exit Sub
    
    
    Err_Print_Record_Click:
        MsgBox Err.Description
        Resume Exit_Print_Record_Click
        
    End Sub

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,822
    Hi
    Is your Form a Single Form View or Continuous?

  3. #3
    steveo0707 is offline Novice
    Windows 11 Office 365
    Join Date
    Oct 2023
    Posts
    20
    Hello,

    It is continuous.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    You open the report hidden.
    You would then OutputTo a pdf file
    Then close the report.

    When you open the report you would use criteria to limit the contents of the report.

    If you Google you will get plenty of examples.

    https://www.google.com/search?q=save...hrome&ie=UTF-8
    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
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,569
    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

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

Similar Threads

  1. Replies: 15
    Last Post: 03-07-2023, 01:43 PM
  2. Replies: 2
    Last Post: 11-13-2017, 08:51 AM
  3. Subform Data Entry Button - Search Button
    By thaBadfish in forum Forms
    Replies: 11
    Last Post: 06-23-2015, 03:14 PM
  4. Replies: 3
    Last Post: 10-20-2014, 03:25 PM
  5. Replies: 3
    Last Post: 10-08-2012, 08:40 AM

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