SubReport RecordSource

B

briank

I would like to eliminate the recordsource for a subreport from a form's
command button. However, upon running my code errors out stating: "The
report name 'rptMABR_blank' you entered is misspelled or refers to a report
that isn't open or doesn't exist". Any ideas how to get a subreport's record
source to = "" ?

Private Sub Command70_Click()
On Error GoTo Err_Command70_Click

Dim stDocName As String
Dim stWhere As String

stDocName = "rptMABR_Blank"
stWhere =
[Reports]![rptMABR_Blank]![rptMABR_pg5_blank].[Report]![sfrmMABR_PlanQ1].RecordSource = ""
DoCmd.OpenReport stDocName, acPreview, , stWhere

Exit_Command70_Click:
Exit Sub

Err_Command70_Click:
MsgBox Err.Description
Resume Exit_Command70_Click

End Sub
 
K

Klatuu

Me.MySubFormControlName.Form.RowSource = vbNullString

Be aware that you use the name of the subform control, not the form that is
the source object of the subform control.
 
B

briank

Dave,
Does your code get entered as a seperate line or at the stWhere section?


Klatuu said:
Me.MySubFormControlName.Form.RowSource = vbNullString

Be aware that you use the name of the subform control, not the form that is
the source object of the subform control.
--
Dave Hargis, Microsoft Access MVP


briank said:
I would like to eliminate the recordsource for a subreport from a form's
command button. However, upon running my code errors out stating: "The
report name 'rptMABR_blank' you entered is misspelled or refers to a report
that isn't open or doesn't exist". Any ideas how to get a subreport's record
source to = "" ?

Private Sub Command70_Click()
On Error GoTo Err_Command70_Click

Dim stDocName As String
Dim stWhere As String

stDocName = "rptMABR_Blank"
stWhere =
[Reports]![rptMABR_Blank]![rptMABR_pg5_blank].[Report]![sfrmMABR_PlanQ1].RecordSource = ""
DoCmd.OpenReport stDocName, acPreview, , stWhere

Exit_Command70_Click:
Exit Sub

Err_Command70_Click:
MsgBox Err.Description
Resume Exit_Command70_Click

End Sub
 
K

Klatuu

As a separate Line. If there is any filtering in the Row Source, it is a
Where Condition in the Row Source property. The code I posted actually makes
the subform an unbound form. You can create the row source at run time with:
Me.MySubFormControlName.Form.RowSource = "SELECT * FROM SomeTable WHERE
[FooBar] = 'Fried';"
--
Dave Hargis, Microsoft Access MVP


briank said:
Dave,
Does your code get entered as a seperate line or at the stWhere section?


Klatuu said:
Me.MySubFormControlName.Form.RowSource = vbNullString

Be aware that you use the name of the subform control, not the form that is
the source object of the subform control.
--
Dave Hargis, Microsoft Access MVP


briank said:
I would like to eliminate the recordsource for a subreport from a form's
command button. However, upon running my code errors out stating: "The
report name 'rptMABR_blank' you entered is misspelled or refers to a report
that isn't open or doesn't exist". Any ideas how to get a subreport's record
source to = "" ?

Private Sub Command70_Click()
On Error GoTo Err_Command70_Click

Dim stDocName As String
Dim stWhere As String

stDocName = "rptMABR_Blank"
stWhere =
[Reports]![rptMABR_Blank]![rptMABR_pg5_blank].[Report]![sfrmMABR_PlanQ1].RecordSource = ""
DoCmd.OpenReport stDocName, acPreview, , stWhere

Exit_Command70_Click:
Exit Sub

Err_Command70_Click:
MsgBox Err.Description
Resume Exit_Command70_Click

End Sub
 

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