OpenArgs and reports

B

Bryan

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
 
B

Bryan

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
 
B

Bryan

Ken,
Now i am getting an error when i run the form leading up to the report.
it states that my report is not bound. any ideas?

Ken Snell said:
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>




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]

When does this error occur? What does the form do? Does the form call the
report using a WHERE argument in the OpenReport action?

--

Ken Snell
<MS ACCESS MVP>

Bryan said:
Ken,
Now i am getting an error when i run the form leading up to the
report.
it states that my report is not bound. any ideas?

Ken Snell said:
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!

:

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>




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 just looked at your earlier OpenReport code step:

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

Your syntax is incorrect for this call, as you're missing two commas:

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

--

Ken Snell
<MS ACCESS MVP>

Bryan said:
Ken,
Now i am getting an error when i run the form leading up to the
report.
it states that my report is not bound. any ideas?

Ken Snell said:
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!

:

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>




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
 
B

Bryan

up and running, thanks Ken! the missing commas fixed it. i will have to
remember the 6 items there.

Ken Snell said:
I just looked at your earlier OpenReport code step:

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

Your syntax is incorrect for this call, as you're missing two commas:

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

--

Ken Snell
<MS ACCESS MVP>

Bryan said:
Ken,
Now i am getting an error when i run the form leading up to the
report.
it states that my report is not bound. any ideas?

Ken Snell said:
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>

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

:

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>




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

Top