I have four unbound main reports each holding two subreports that are independent of each other. I am trying to write a module that will use variables to open the main reports. If both subreports have no data, I want a message box stating that there are no records. I have buttons for each of the reports on a form. I am have having a terrible time referencing the subreports using variables. I can get it to work by not using variables which makes for lengthy code.
Dim strReport As String 'The name of the main report.
Dim strMain As String 'A variable naming one of the subreports attached to the main report.
Dim strRemote As String 'A variable naming the other subreport attached to the main report.
Dim varMain 'A varible to hold the .HasData value for strMain.
Dim varRemote 'A variable to hold the .HasData value for strRemote.
strReport = Screen.ActiveControl.Name
DoCmd.OpenReport strReport, acViewPreview
strMain = Screen.ActiveReport![Main].Report.Name
strRemote = Screen.ActiveReport![Remote].Report.Name
varMain = (THIS IS WHERE MY PROBLEM IS COMING IN)
varRemote =
If varMain = 0 And varRemote = 0 Then
DoCmd.Close
MsgBox "No records available", vbOKonly
End If
End Function
I really appreciate any thoughts or recommendations.
Thank you very much,
Linda
Dim strReport As String 'The name of the main report.
Dim strMain As String 'A variable naming one of the subreports attached to the main report.
Dim strRemote As String 'A variable naming the other subreport attached to the main report.
Dim varMain 'A varible to hold the .HasData value for strMain.
Dim varRemote 'A variable to hold the .HasData value for strRemote.
strReport = Screen.ActiveControl.Name
DoCmd.OpenReport strReport, acViewPreview
strMain = Screen.ActiveReport![Main].Report.Name
strRemote = Screen.ActiveReport![Remote].Report.Name
varMain = (THIS IS WHERE MY PROBLEM IS COMING IN)
varRemote =
If varMain = 0 And varRemote = 0 Then
DoCmd.Close
MsgBox "No records available", vbOKonly
End If
End Function
I really appreciate any thoughts or recommendations.
Thank you very much,
Linda