Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open report without printing using DoCmd

Status
Not open for further replies.

roddy17

Technical User
Jul 27, 2001
49
0
0
CA
hi there,
i have a report that i want to open, but using the DoCmd method sends it to print. On the form is a combo box which has a list of mandates to choose from. When a mandate is chosen, the rest of the information is displayed in the tab display beneath the combo box. I want to open a report but then only print the current record displayed. But first, i think that I need to open the report without printing so that i can tell the report which record to print. Is this right? s-)
This is the code that i've started to use. I'm not even sure if it will do what i need it to.

Private Sub cmdPrintStatement_Click()
' Want to only print the statement for the Investment Mandate currently displayed.
'DoCmd.OpenReport "Policy Statement"

Dim stDocName As String
stDocName = "Policy Statement"
Dim stLinkCriteria As String

stLinkCriteria = "[Mandate Name] = " & Me![txtTabInvestMandate] '.Column(0)
DoCmd.OpenReport stDocName
Reports.Item("Policy Statement").RecordsetClone.FindFirst stLinkCriteria
Reports.Item("Policy Statement").Bookmark = Reports.Item("Policy Statement").RecordsetClone.Bookmark


End Sub

Can you help me with this?
thankyou very much
 
Hi!

Try this:

Private Sub cmdPrintStatement_Click()
' Want to only print the statement for the Investment Mandate currently displayed.
'DoCmd.OpenReport "Policy Statement"

Dim stDocName As String
stDocName = "Policy Statement"
Dim stLinkCriteria As String

stLinkCriteria = "[Mandate Name] = " & Me![txtTabInvestMandate] '.Column(0)
DoCmd.OpenReport stDocName, acViewPreview, stLinkCriteria

End Sub

hth Jeff Bridgham
bridgham@purdue.edu
 
hey there, me again
I didn't explain my problem well enough, i'm sorry. :)
Let me try again. I do need to print the report, but i need Access to populate the fields on the report before printing it. That is why i'm trying to find a different way to open it, so that Access matches up the field of information that i'm basing the report on, then grabs the rest of the record related to that field and then prints the report. Right now, Access just prints the report for every record in my main table, when i only want a specific record of information based on a common field (the primary key) that i will select from.
What i have below is similar code that i used to do the same thing except display the related record information (for only that record) on another form,, except now i wanna do that for a report.
Private Sub cmdPortfolioManager_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Portfolio Manager"

If Me!cboPortfolioManager <> &quot;&quot; Then
stLinkCriteria = &quot;[Manager Id] = &quot; & Me![cboPortfolioManager].Column(0)
DoCmd.OpenForm stDocName
Forms.Item(&quot;Portfolio Manager&quot;).RecordsetClone.FindFirst stLinkCriteria
Forms.Item(&quot;Portfolio Manager&quot;).Bookmark = Forms.Item(&quot;Portfolio Manager&quot;).RecordsetClone.Bookmark
Else
DoCmd.RunMacro &quot;MsgBox - No Portfolio Manager&quot;
End If
End Sub

This code works great for the form. So i thought that i could use some similar rendition of it for my report.

hopefully this explanation is more clear of what i'm trying to do.
and thanks vm for your willingness to help.

roddy
 
Hi Roddy!

I'll stand by my original reply with one change:

DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

Of course, if you want the report to print, then leave out the acViewPreview. Putting the stLinkCriteria in the OpenReport command will limit the recordsource of the report by the condition.

hth
Jeff Bridgham
bridgham@purdue.edu
 
well, i gave that a shot but it's giving me an error message -
Run-time error '3075'
Syntax error (missing operator in query expression '([Mandate Name]= . . .

It's interesting. I'm trying a few different things to see if i can get this to do what i want. Apparently i'm still not doing enough filtering, or something..
anyways, i'm not giving up on this.
thanks
 
Hi!

Try this for stLinkCriteria:

stLinkCriteria = &quot;[Mandate Name] = '&quot; & Me!txtTabInvestMandate & &quot;'&quot;

hth
Jeff Bridgham
bridgham@purdue.edu
 
hi Jeff,
by gosh i think we've got it.
With your ammendment to the code and a couple of other subtle changes, this report thing is working.
and thanks to you, i will be able to make the deadline to have this database system online for testing.
again, thanks vm
roddy
 
Hey Roddy!

That's excellent! Glad to be of help!

Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top