SubReport RecordSource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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,
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
 
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
 
Back
Top