OpenArgs and reports

G

Guest

ok, i am passing values from a list to try and generate a report. i have the
current code on the form i am getting my value from.

DoCmd.OpenReport "Detailed_School", acViewPreview, acWindowNormal,
OpenArgs:=strID

on my report i have the following:
Private Sub Report_Open(Cancel As Integer)
Dim strID As String


strID = Me.OpenArgs
End Sub

and lastly, my query that the report runs off of:
SELECT [SchoolDB].*
FROM [SchoolDB]
WHERE ((([SchoolDB].ID)=Reports!rptDetails!strID));

when i run the forums, i get a blank report. what am i missing?

thanks,
Bryan
 
K

Ken Snell [MVP]

A query (nor other objects, for that matter) cannot read the value of a
variable that is in your report's module.

In your situation, I would be inclined to set the report's recordsource
directly to the SQL statement:

Private Sub Report_Open(Cancel As Integer)
Dim strID As String
strID = Me.OpenArgs
Me.RecordSource = "SELECT [SchoolDB].* " & _
"FROM [SchoolDB] WHERE [SchoolDB].ID)='" & _
strID & "';"
End Sub
 
G

Guest

excellent i will try that and report back. thanks Ken!

Ken Snell said:
A query (nor other objects, for that matter) cannot read the value of a
variable that is in your report's module.

In your situation, I would be inclined to set the report's recordsource
directly to the SQL statement:

Private Sub Report_Open(Cancel As Integer)
Dim strID As String
strID = Me.OpenArgs
Me.RecordSource = "SELECT [SchoolDB].* " & _
"FROM [SchoolDB] WHERE [SchoolDB].ID)='" & _
strID & "';"
End Sub


--

Ken Snell
<MS ACCESS MVP>




Bryan said:
ok, i am passing values from a list to try and generate a report. i have
the
current code on the form i am getting my value from.

DoCmd.OpenReport "Detailed_School", acViewPreview, acWindowNormal,
OpenArgs:=strID

on my report i have the following:
Private Sub Report_Open(Cancel As Integer)
Dim strID As String


strID = Me.OpenArgs
End Sub

and lastly, my query that the report runs off of:
SELECT [SchoolDB].*
FROM [SchoolDB]
WHERE ((([SchoolDB].ID)=Reports!rptDetails!strID));

when i run the forums, i get a blank report. what am i missing?

thanks,
Bryan
 
K

Ken Snell [MVP]

I should correct one part of my initial answer. A form or report can read
the value of a variable in another form or report IF you declare that
variable as a public variable in the module.

--

Ken Snell
<MS ACCESS MVP>

Bryan said:
excellent i will try that and report back. thanks Ken!

Ken Snell said:
A query (nor other objects, for that matter) cannot read the value of a
variable that is in your report's module.

In your situation, I would be inclined to set the report's recordsource
directly to the SQL statement:

Private Sub Report_Open(Cancel As Integer)
Dim strID As String
strID = Me.OpenArgs
Me.RecordSource = "SELECT [SchoolDB].* " & _
"FROM [SchoolDB] WHERE [SchoolDB].ID)='" & _
strID & "';"
End Sub


--

Ken Snell
<MS ACCESS MVP>




Bryan said:
ok, i am passing values from a list to try and generate a report. i
have
the
current code on the form i am getting my value from.

DoCmd.OpenReport "Detailed_School", acViewPreview, acWindowNormal,
OpenArgs:=strID

on my report i have the following:
Private Sub Report_Open(Cancel As Integer)
Dim strID As String


strID = Me.OpenArgs
End Sub

and lastly, my query that the report runs off of:
SELECT [SchoolDB].*
FROM [SchoolDB]
WHERE ((([SchoolDB].ID)=Reports!rptDetails!strID));

when i run the forums, i get a blank report. what am i missing?

thanks,
Bryan
 

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

Similar Threads


Top