Solved Report gets sent to Printer Automatically?

Weekleyba

Registered User.
Local time
Yesterday, 20:18
Joined
Oct 10, 2013
Messages
586
I'm puzzled on this one.
I have continuous form, that has a command button that executes on click the follow code.
Code:
Private Sub buttonOpenReport_Click()
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Location_Funded_Letter2020_R"
    
    stLinkCriteria = [Location_Description] = "'" & Me![Location_Description] & "'"
    
    DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria
    
End Sub

When I click the command button, the printer dialog box flashes quickly and it gets sent to the printer and prints.
Problem is, I don't want it sent to the printer, I just want the report to open.

What's wrong here?

1615587865857.png
 
Yep, that was it! Thanks.

Problem #2
It is not bring up the report with the matching Location Description. These are both text fields.
Do I not have the quotes in the right places?

Code:
    stLinkCriteria = [Location_Description] = "'" & Me![Location_Descriptions] & "'"
 
Found it.
Code:
    stLinkCriteria = "[Location_Description] =" & "'" & Me![Location_Descriptions] & "'"
I always get messed up on those.
 
Or use this simpler version

Code:
stLinkCriteria = "[Location_Description] ='" & Me.[Location_Descriptions] & "'"
 
This would also work?
Code:
 stLinkCriteria = "[Location_Description] =''" &  Me![Location_Descriptions] & "'"

But as long as you work out the parts of the statement, it does not matter much at all. :)

Edit: Oh so slow, :( but at least my thoughts are duplicated? :)
 
Hi Paul
No that wouldn't work. Extra single quote after the = sign
Both Me. and Me! will work however.
 

Users who are viewing this thread

Back
Top Bottom