Solved

Create a report from current record in form

Posted on 2001-06-06
3
202 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 100 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

803 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