VBA- Help setting up a print screen button on a form based on search results

jaywan91

New member
Local time
Today, 04:53
Joined
Apr 19, 2017
Messages
4
On my project, the main form "frmMain3" has 4 search boxes that can search 4 separate columns on the split form (since I couldn't set up one search box for the entire file but thats another issue). These search boxes are "Search_box", "Customer_Search", DivDir_Search" and "Project_Search" respectively. Once I search for something in a certain search box, it filters the form below based on what I typed in the box.

Now the issue, I want to have MS Access open a print preview screen (in landscape mode) when I click a button based on the filtered results of the search box. However, the best I've been able to generate is an unfiltered print preview screen. Any way to do this?

My code so far that now outputs a type mismatch error:

Code:
Private Sub Print_Click()

Dim myform As Form
    Set myform = Screen.ActiveForm
    DoCmd.SelectObject acForm, myform.Name, True
    DoCmd.OpenForm frmMain3, acPreview
    DoCmd.SelectObject acForm, myform.Name, False
 
End Sub
 
Most of us would create a report for printing. You have a lot more control over the look and feel. You can pass the form's filter in the wherecondition argument of OpenReport.
 
Most of us would create a report for printing. You have a lot more control over the look and feel. You can pass the form's filter in the wherecondition argument of OpenReport.

How would you do set that up in the where condition? Can I get it to output a report based on the filters I set up in the search boxes and output that report into print preview?
 
Presuming you're manipulating the filter property, you should be able to pass

Me.Filter

in the wherecondition. If you're manipulating the record source, you can pass that in OpenArgs.
 

Users who are viewing this thread

Back
Top Bottom