Print Access MDB name on reports

M

Michael M. Mahoney

I have several Access MDB which uses linked files from an SQL server. They
all uses the same files, but have different queries, reports, etc. These are
for different departments. Some reports are in more than one MDB. When a
user reports a problem, or requests a change, I need to know which MDB they
were using.
What I wish to do is include the Access MDB name on the printed reports. Is
there a way to get the MDB name and use it in a report field?

Michael M. Mahoney
Monterey Financial Services, Inc.
(e-mail address removed)
 
L

Larry Daugherty

You might try Application.name or Application.FullNme (gets the
complete pathname) in a textbox in the header or footer of your
reports.
 
F

fredg

I have several Access MDB which uses linked files from an SQL server. They
all uses the same files, but have different queries, reports, etc. These are
for different departments. Some reports are in more than one MDB. When a
user reports a problem, or requests a change, I need to know which MDB they
were using.
What I wish to do is include the Access MDB name on the printed reports. Is
there a way to get the MDB name and use it in a report field?

Michael M. Mahoney
Monterey Financial Services, Inc.
(e-mail address removed)

Use an unbound text control.
=[CurrentDb].[Name]
 
O

Ofer Cohen

In the report you can create a text box and in the control source you can write

=Mid(Application.CurrentDb.Name,InStrRev(Application.CurrentDb.Name,"\")+1)

If you want to add the path to the mdb, write

=Application.CurrentDb.Name
 
A

Aaron Kempf

no those DAO dorks don't know about CurrentProject

they just thnk that they're stuck using CurrentDB




Graham Mandeno said:
Hi Larry

I think you mean "CurrentProject", not "Application".
--
Cheers :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Larry Daugherty said:
You might try Application.name or Application.FullNme (gets the
complete pathname) in a textbox in the header or footer of your
reports.
 
M

Michael M. Mahoney

"Joseph Meehan" wrote:

Joseph,

That is what I do now. The problem is, when I update a report, and then
distribute (export) it to all the other MDBs that use it, I would have to
then go into each MDB and edit the report to the correct name. I am looking
for a way to have the report or query automatically retrieve the name of the
MDB it is running in, and include it on the report. So if a user sent me a
printed report, with a reqeust or bug report, I would know which database was
the source.

Thanks,

Michael M. Mahoney
Monterey Financial Services, Inc.
(e-mail address removed)
 
A

Aaron Kempf

uh loop through all your reports and add a label?

I dont' think that it would take me more than a couple of minutes



this is something simliar for reports; but i'm going through and scrubbing
some sql statements.. adding a control should jsut be a couple of lines of
code


Public Sub FixAllReports_subReportSourceObject()
On Error GoTo errHandler

Dim thisFrm As Report
Dim frm As AccessObject
Dim ctl As Control
Dim newCtlName As String

For Each frm In CurrentProject.AllReports
OpenReport frm.Name, acDesign
Set thisFrm = Reports(frm.Name)
For Each ctl In thisFrm.Controls
If ctl.ControlType = 112 Then
newCtlName = Replace(Replace(ctl.SourceObject, " ", ""),
"_", "")
If ctl.SourceObject <> newCtlName Then ctl.SourceObject =
newCtlName

newCtlName = Replace(Replace(ctl.LinkChildFields, " ", ""),
"_", "")
If ctl.LinkChildFields <> newCtlName Then
ctl.LinkChildFields = newCtlName

newCtlName = Replace(Replace(ctl.LinkMasterFields, " ", ""),
"_", "")
If ctl.LinkMasterFields <> newCtlName Then
ctl.LinkMasterFields = newCtlName

End If
Next ctl
'DoCmd.Save acForm, frm.Name
DoCmd.Close acReport, frm.Name, acSaveYes
Next frm

cleanExit:
Exit Sub
errHandler:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly
Resume Next
Resume
End Sub
 
M

Michael M. Mahoney

Thanks, Ofer, this is exactly what I was looking for. It works great.


Michael M. Mahoney
 

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