?
Solved

Create a report from current record in form

Posted on 2001-06-06
3
Medium Priority
?
222 Views
Last Modified: 2012-06-27
  I have a form (frmProposal) which gets its data from a query that combines two tables (tblCustomers and tblBidDescription).  There is a report (rptProposal) that uses  the data from another query (qryProposal) to generate (surprise!!) a proposal.  I am looking to open the rptProposal from the frmProposal using the [ProposalNumber] on the frmProposal.  I have tried using an EventProcedure in the OnClick property of the Command Button that opens rptProposal:

Private Sub PreviewProposal_Click()

On Error GoTo Err_PreviewProposal_Click

    Dim stDocName As String
    stDocName = "rptProposal"

    DoCmd.OpenReport stDocName, acPreview, "[ProposalNumber]=" = Me![ProposalNumber]

Exit_PreviewProposal_Click:
    Exit Sub

Err_PreviewProposal_Click:
    MsgBox Err.Description
    Resume Exit_PreviewProposal_Click

End Sub

However, this still opens ALL proposals.  How can I just get it to open the Report using ONLY the Proposal based off of the record I am working on and not every record in the database.
0
Comment
Question by:thewesties
3 Comments
 
LVL 19

Accepted Solution

by:
frankytee earned 400 total points
ID: 6162127
you are almost there!
you put the filter in the wrong argument (it should be in the WHERE argument and not the filtername)

just add an extra comma and alter the your filter with the ampersand (&), ie
DoCmd.OpenReport stDocName, acPreview, ,"[ProposalNumber]=" & Me![ProposalNumber]

0
 
LVL 6

Expert Comment

by:Mach1pro
ID: 6162130
Try this:

DoCmd.OpenReport stDocName, acPreview, "[ProposalNumber]=" &  Me![ProposalNumber]
0
 

Author Comment

by:thewesties
ID: 6162313
Thank you.  I was batting my head against a wall.  Thought I tried that.  Must have been a brain fart!!  Regards, Westy
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question