steveo0707
New member
- Local time
- Yesterday, 21:09
- Joined
- Aug 2, 2024
- Messages
- 1
Hello,
I am using Microsoft 365.
I have a db that tracks nonconformance parts. 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
I am using Microsoft 365.
I have a db that tracks nonconformance parts. 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