removing unused queries, forms etc.

G

Guest

I have been developing a new ordering database which has included me learning
Access. Along the way I have created lots of queries and forms to try things
out but now I am not sure which ones I actually use and which ones I can get
rid of. I know there are also some queries which are the same as others with
different names.
To avoid me having to go through every form used trying to work out which I
need and which I don't does anyone know of a way I can get a list of queries
etc. used for every form used, or something similar.
I would be exceedingly grateful for any help.
 
D

Douglas J. Steele

There's really nothing built into Access. While you could loop through all
the forms, opening each so that you see what its RecordSource is, you might
still miss queries being used as the RowSource for combo or list boxes,
plus any queries that are called in VBA.

Total Access Analyzer, from FMS, can help you
http://www.fmsinc.com/products/analyzer/index.html (although it's not going
to be able to tell you duplicate queries with different names)
 
B

Brendan Reynolds

Zedbiker said:
I have been developing a new ordering database which has included me
learning
Access. Along the way I have created lots of queries and forms to try
things
out but now I am not sure which ones I actually use and which ones I can
get
rid of. I know there are also some queries which are the same as others
with
different names.
To avoid me having to go through every form used trying to work out which
I
need and which I don't does anyone know of a way I can get a list of
queries
etc. used for every form used, or something similar.
I would be exceedingly grateful for any help.


Here's something I posted recently in response to a similar question ...

<quote>
I don't think there is any 100% foolproof method. For example it is possible
to have code such as this in the Open method of a form ...

Const strcQueryName = "qryExample"
If SomeCondition = True Then
Me.RecordSource = strcQueryName & "ByName"
Else
Me.RecordSource = strcQueryName & "ByNumber"
End If

I don't think there is any tool that will reliably detect that this form is
dependant on both qryExampleByName and qryExampleByNumber.

With that caveat, there are some tools that can help ...

Find and Replace
www.rickworld.com

Total Access Analyzer
www.fmsinc.com

SPEED Ferret
www.moshannon.com
</quote>

There's also the "Object Dependencies" feature in recent versions of Access.
The following on-line help topic has information about this feature and its
limitations ...

http://office.microsoft.com/client/...=2&ns=MSACCESS&lcid=2057&pid=CH100645691033#4
 
G

Guest

Many thanks for that but I can't see my boss allowing me to spend $299 on
this package which will probably only be used once or twice. Although messy I
might just have to leave it as it is and be more aware of this if I write any
more databases in future.
 
S

Scott McDaniel

Many thanks for that but I can't see my boss allowing me to spend $299 on
this package which will probably only be used once or twice. Although messy I
might just have to leave it as it is and be more aware of this if I write any
more databases in future.

I'd second Doug's recommendation of TAA. I use it regularly and have found it to be a pretty good tool, but you're right
- it is pricey for a one or two time use.

As an alternative, you could add some sort of "logging" feature that would show when each form/report is opened, then
let the db run for a month or so, then review that log and see what forms are being used. Something like this:

tObjectLog
------------------
ColumnName DataType
------------------------------------
lID AutoNumber (PK - this field is optional)
sName Text
iType Numeric
dTimeStamp Date

Now add a function in a Standard Module:

Function LogObject(ObjectName As String, ObjectType As AcObjectType) As Boolean

CurrentDb.Execute "INSERT INTO tObjectLog(sName,iType,dTimeStamp) VALUES('" & ObjectName & "'," & ObjectType & ",#" &
Now & "#)"

End Function

Now add this to the Open or Load event or your Forms/Reports:

Sub Form_Open()
LogObject Me.Name, acForm
End Sub

Obviously, change the acForm to acReport when needed.

Once you're satisfied that a form/report is no longer being used, then rename it and make sure nothing breaks ... if,
after another day/week/month you get no errors, the remove it from the database (obviously keep a backup just in case
something happens down the road).

This won't help with queries, of course, but it will pare down those unneeded forms/reports, and you can then review any
queries used on those forms/reports to see if you can remove queries.

Alternatively, you could search the codebase to see if a query is being used. Rick Fishers Find & Replace utility is a
good one (http://www.rickworld.com/products.html) although I've used the one in mztools (www.mztools.com) with good
success (and it's free, and has a LOT of other great goodies!!).

Note that if you've used Macros, I don't know if the mztools search feature will do any good ... don't know about F&R,
but the literature does say it searches Macros. Of course, you really shouldn't be using macros anyway ...


Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
G

Guest

Many thanks everyone for these suggestions.
The Object Dependancies option looks quite good on first reading but I will
give it a try and see.

Many thanks again.
 
D

Dancing Queen

if you used SQL Server and Access Data Projects then you could use profiler
in order to trap all of the SQL that is being submitted to the database

from there; you could write a union statmenet that would go through all your
queries and give the answer to that subquery (are there results in my trace
that correspond to this sproc or view)

it might take 10 minutes but no longer than that
 

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