Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing Subreport variable

Status
Not open for further replies.

Artemus

Technical User
Sep 20, 2002
2
US
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


 
I figured it out. The answer was staring at me -- I was just too blind to see it.

Thank you again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top