Opening Report to Print Preview Mode

Tophan

Registered User.
Local time
Today, 03:09
Joined
Mar 27, 2011
Messages
374
Hello,

I have a report which is accessed via a hyperlink in a form. I have the default view for the report set to Print Preview yet everytime I click the link the report opens in report view which I don't want.

The event for the hyperlink is as follows:

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ContractName] = """ & Me.[ContractName] & """"
DoCmd.OpenReport "RPTSmryDwgRegRpt", acViewPreview, , strWhere
End If
End Sub

I have tried changing "acViewPreview" to "acViewReport" and "acViewNormal" and each time it is either going straight to print or opening in report view. I just want the report to open in print preview mode so I can decide if to print a hard copy or send to pdf

Any suggestions?
 
That looks okay offhand. There isn't any code running in the report when it opens, is there?
 
Set the Allow Report View to No and try again.
 
Ok...changing allow report view to no worked...sort of.

The report is opening in print preview but now I am getting two pop-up message boxes

The first one is - Report View is not available for this report
The second one is - Microsoft Access cannot follow the hyperlink to 'Report RPTSmryDwgRgRpt'. Please verify destination
 
I did notice before that when I clicked the hyperlink the report would open and then re-open really fast (if ya blinked ya missed it). I have checked and cannot find any conflicting events and opening that report is only via the hyperlink. I don't have any other links or buttons in the database that would run that report.
 
Can you post the db here?
 
You use one or the other, not both.

If you want to do it in code and make it look like a Hyperlink do the following:

1. Convert the label to a textbox. Once you've done this there's no Hyperlink SubAddress property so you don't need to worry about this anymore.
2. Set the Display As Hyperlink property to Always
3. Go to the Click event to reactivate the event for opening the report
 
Ok...I'll give it a try and let you know if I got it to work. As always you're a great help :)

ps. I removed the database from my earlier post
 
That's fine.

If you still want it as a label then you need to remove the event code. But I see that you're performing other checks in there so it's best to have it as a textbox by following the steps mentioned.
 
It worked! Thank you very much.

I have one more question regarding a hyperlink but it pertains to Forms so I will post it in the correct forum.

Thanks again
 

Users who are viewing this thread

Back
Top Bottom