Report not opening correctly

  • Thread starter Thread starter Susanne
  • Start date Start date
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.
 
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.
 
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.
 
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.
 
Back
Top