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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve current report name

Status
Not open for further replies.

DH

Programmer
Dec 8, 2000
168
Is there a way to retreive the current report name using VB and place the report name in a variable?

Not having any luck figuring this one out.

DH
 
Hi,

You need something like this (if this doesn't work for a report). Problem is, you may have numerous reports or forms runing at the same time.

This function tells you if a 'particular' form IS running.

If this doesn't work for reports, then look at "report collection" in Access help - will be same function with different reference.

Code:
Function IsLoaded(MyFormName)
' Accepts: a form name
' Purpose: determines if a form is loaded
' Returns: True if specified the form is loaded;
'          False if the specified form is not loaded.
    
    Dim i

    IsLoaded = False
    For i = 0 To Forms.Count - 1
        If Forms(i).FormName = MyFormName Then
            IsLoaded = True
            Exit Function       ' Quit function when found.
        End If
    Next

End Function

If you are absolutely sure that only one form or report is open when you use the function, then this function will be easy to change - to suit.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Public strReportName as String
Public Function funReportName
Msgbox "The report name is " & strReportName
End Function

Then in the Open Event for the Report you put

strReportName = Me.Name
Call funReportName()

You will get a message box that diplays the Report Name and the variable strReportName will hold that value.

Paul
 
Hi,

Paul, this is a joke of course.

What you are doing is setting a Global variable in each and EVERY report that has to set a global variable.

GH - ignore this - it's atrocious.

There IS a better way - re-post the question f.c.s., before you do this. (You would have to do this in EVERY report and EVERY form for that matter).

Kind regards,

Darrylle


"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top