Button to update/save, select record and print

tim1234

Registered User.
Local time
Today, 16:41
Joined
Nov 19, 2002
Messages
38
Hi, I have a database that works but I want to make it easier to use. Right now the user must enter their information into the form, click save, click print, (a different form based on a query opens), enter the form # to print and click OK.

The first form is to make data entry easier and the second is formatted for printing. I'm sure that there is a way to make the print button first save the record, and then pull the form number instead of having to enter it in the parameter box.

The first form is the NCMR (NonConforming Material Report) with the print button.
The second is called print NCMR and is based on a query of the same name. It just uses the parameter (Like [Enter NCMR #] to select correct record.
The number that must be entered to print the record is the autonumber (NCMR) that the form gives the record.

Any help is very appreciated.
 
I think you should be able to put a docmd.save before the print command. Then just use the forms text box control name for the record number as a criteria in the reports underlying query.

:)
ken
 
Button

Please excuse my ignorance here. Does that go in the code for the button itself?

Here is what the button has now.

Private Sub printer_Click()
On Error GoTo Err_printer_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "PrintNCMR"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_printer_Click:
Exit Sub

Err_printer_Click:
MsgBox Err.Description
Resume Exit_printer_Click

End Sub

Thanks for your help
 
First Question.
are you printing the form or a report?

make the second form a report based on the same query.
On the first form (NCMR) Print Button on click event enter the following code

Dim stDocName As String
Dim strFilter As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


stDocName = "Your ReportName"

strFilter = "[NCMR#]=" & Me![NCMR#]
DoCmd.OpenReport stDocName, acViewNormal, strFilter
DoCmd.Close acForm, "NCMR"
This is if you want to preview the Report first


To print directly use

DoCmd.OpenReport stDocName, acNormal,strFilter instead.
 
First Question.
are you printing the form or a report?

make the second form a report based on the same query.
On the first form (NCMR) Print Button on click event enter the following code

Dim stDocName As String
Dim strFilter As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


stDocName = "Your ReportName"

strFilter = "[NCMR#]=" & Me![NCMR#]
DoCmd.OpenReport stDocName, acViewNormal, strFilter
DoCmd.Close acForm, "NCMR"
This is if you want to preview the Report first


To print directly use

DoCmd.OpenReport stDocName, acNormal,strFilter instead.
 
Reply

I tried to make it a report first, but it said I chose too many fields. So I made it a form and it took all of the fields. Is there any other way to get all of the fields into the report?
 
Yes ,If am right you tried to use a wizard and the fields were more.What you do is use the wizard with a few fields then you add the others manually.Open the report in design view and add the fields not generated by the wizard.
If you still feel you want to print the form replace the names Report with Form and use the second form name.
If not sure use the command button wizard to generate the code for you then copy and paste to the code I pasted
 
Reply

Yes, you're correct. I created the report in design view and I am working on getting the code into the button. Thanks very much for your help. Hopefully I'll have it going in a little while.
 

Users who are viewing this thread

Back
Top Bottom