Report not opening correctly

S

Susanne

I want to link a report based on criteria from a search form. Do I need to
set the report recordsource to a query based on the search form or can I just
link it like I can with a form?

I'm using the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[DiveSuit_Number]=" & "'" & Me![lst_Dive] & "'"
stDocName = "rpt_DiveRecord_PageSign"
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

And it is opening up all the records, not just the one that is selected.
 
S

Susanne

Ah! The mystery comma! Took me a moment to see the difference. Thanks!

Douglas J. Steele said:
That should be

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susanne said:
I want to link a report based on criteria from a search form. Do I need to
set the report recordsource to a query based on the search form or can I
just
link it like I can with a form?

I'm using the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[DiveSuit_Number]=" & "'" & Me![lst_Dive] & "'"
stDocName = "rpt_DiveRecord_PageSign"
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

And it is opening up all the records, not just the one that is selected.
 
D

Douglas J. Steele

The actual syntax for the OpenReport method is

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

If you want to ignore a parameter, you either need to leave it out but still
include the comma(s) for it, or else use named parameters:

DoCmd.OpenReport stDocName, acPreview, WhereCondition:=stLinkCriteria


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susanne said:
Ah! The mystery comma! Took me a moment to see the difference. Thanks!

Douglas J. Steele said:
That should be

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susanne said:
I want to link a report based on criteria from a search form. Do I need
to
set the report recordsource to a query based on the search form or can
I
just
link it like I can with a form?

I'm using the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[DiveSuit_Number]=" & "'" & Me![lst_Dive] & "'"
stDocName = "rpt_DiveRecord_PageSign"
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

And it is opening up all the records, not just the one that is
selected.
 
S

Susanne

Thanks. I did get it with the missing comma. I realized I placed my
criteria in the wrong parameter location.

Douglas J. Steele said:
The actual syntax for the OpenReport method is

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

If you want to ignore a parameter, you either need to leave it out but still
include the comma(s) for it, or else use named parameters:

DoCmd.OpenReport stDocName, acPreview, WhereCondition:=stLinkCriteria


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Susanne said:
Ah! The mystery comma! Took me a moment to see the difference. Thanks!

Douglas J. Steele said:
That should be

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I want to link a report based on criteria from a search form. Do I need
to
set the report recordsource to a query based on the search form or can
I
just
link it like I can with a form?

I'm using the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[DiveSuit_Number]=" & "'" & Me![lst_Dive] & "'"
stDocName = "rpt_DiveRecord_PageSign"
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

And it is opening up all the records, not just the one that is
selected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top