Print report of found record from a form

RDSJMS

Registered User.
Local time
Today, 16:05
Joined
Jan 25, 2006
Messages
30
I've created a multiuser DB with a tabbed form interface. There are separate forms to (1) find a record, (2) create a new record, (3) edit an existing record, (4) duplicate then change a record. I need to print a report based upon the current record in any of these form.

I've read many other posts on this general topic and am getting more confused with each post I read. Many here have a lot of what appear to be great ideas, but I cannot yet comprehend the macro and/or VBA module concepts. I've tried copying examples I've found posted here, but I must be doing something wrong as none have worked in my DB.

Can someone point me in the right direction please.
 
Pat,

Thank you for the reply. I'm closer, but not there yet.

The following is the code associated with a "Print Preview" button on the form. The data is populated on the form from a parameter query. To this form I added the "Print Preview" button created using the command button wizard. The problem now is that the "Print Preview" button is prompting for the "Item Code" again before the report is displayed in preview mode, which is not what I want to happen.

Can you help further please.


Private Sub Print_Preview_Click()
On Error GoTo Err_Print_Preview_Click

Dim stDocName As String
Dim strWhere As String

strWhere = [Item Code] = Forms![frm_Find an existing Packaging Spec]![Item Code]
stDocName = "rpt_Print 1 Packaging Spec with Revision History"
DoCmd.OpenReport stDocName, acPreview

Exit_Print_Preview_Click:
Exit Sub

Err_Print_Preview_Click:
MsgBox Err.Description
Resume Exit_Print_Preview_Click

End Sub

End Sub
 
I've replaced my bad code with yours and I get a "Type Mismatch" error. Trying to follow the popup syntax example:

By adding 1 comma, I'm prompted for the "Item Code" again.

By adding 2 commas, I get a "Compile Error: Wrong number of arguments or wrong property assignment.

By removing 1 comma, I'm prompted for the "Item Code" twice.

By removing 2 commas, I'm prompted for the "Item Code" again.

I'm frustrated.
 
Last edited:
Yes, the Item Code is text.

As before, I do get the report for the Item Code requested, but the code is still prompting me to re-input the Item Code when clicking the command button, which is not what I want the users to have to do. Is there any way around that?

Thanks for the tip on not using spaces. Can I make changes to eliminate the spaces and have Access change all occurrances/dependencies automatically? I have "Track name AutoCorrect info" and "Perform name AutoCorrect" both checked.
 
I checked for typos and found none.

The form that I put the command button on calls a parameter query when the user is "finding" an "Item Code". The report that I am calling with the command button uses the same parameter query. The report is on a reports switchboard.

Do I need another version of this report that is not based on a parameter query? I was trying to re-use an existing report and have the command button grab the current record being displayed on the form to generate the report from.
 

Users who are viewing this thread

Back
Top Bottom