Solved Report gets sent to Printer Automatically?

Weekleyba

Registered User.
Local time
Today, 02:58
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
 

Weekleyba

Registered User.
Local time
Today, 02:58
Joined
Oct 10, 2013
Messages
586
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] & "'"
 

Weekleyba

Registered User.
Local time
Today, 02:58
Joined
Oct 10, 2013
Messages
586
Found it.
Code:
    stLinkCriteria = "[Location_Description] =" & "'" & Me![Location_Descriptions] & "'"
I always get messed up on those.
 

isladogs

MVP / VIP
Local time
Today, 08:58
Joined
Jan 14, 2017
Messages
18,209
Or use this simpler version

Code:
stLinkCriteria = "[Location_Description] ='" & Me.[Location_Descriptions] & "'"
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:58
Joined
Sep 21, 2011
Messages
14,232
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? :)
 

isladogs

MVP / VIP
Local time
Today, 08:58
Joined
Jan 14, 2017
Messages
18,209
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

Top Bottom