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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report parameter 1

Status
Not open for further replies.

abdhab

MIS
Dec 10, 2006
51
CA
is there a way to add a parameter to a report, so i can only view data which match my parameter criteria?

i know it can be done easily with a query.. the problem is i already finished the design of the report and it really took a lot of time, i dont wanna redo the same report for a new query..

thanks in advance
 
You should not need to change the report design if you change the query. If you create a new query, you can set the record source of the of the report to the name of the new query. Alternatively, you can use a Where statement:

[tt]DoCmd.OpenReport "rptReport", , , "SomeField='ABC' AND SomeOtherField=2"[/tt]
 
ok thanks, this is what i need
i tried it like the following:

Me.id.SetFocus
DoCmd.OpenReport stDocName, acPreview, , "id" = Me.id.Text

but it gave me a report with no data
am i missing something?
 
ok done
just edited the code

Me.id.SetFocus
var = Me.id.Text
DoCmd.OpenReport stDocName, acPreview, , "id = " + var

 
You don't have to set focus to a control to get its value. Use the "Value" property rather than the "Text" property. The Value property is the default property so it can be left off your expression. I would also recommend "&" for concatenating strings.

Code:
    var = Me.id
    DoCmd.OpenReport stDocName, acPreview, , "id = " & var

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top