Access CommandButton "On Click" property

  • Thread starter Thread starter Matt Williamson
  • Start date Start date
M

Matt Williamson

I have a number of Access 97 Databases that were poorly designed and contain
alot of extraneous garbage that needs to be cleaned up. The form UI consists
of MANY command buttons, all linked to another form, query or report or
event proc that calls any of those 3 through code. What I'd like to
accomplish is to determine what each command button is linked to and make a
list with the name of the button and what it is linked to. Is this possible
programatically from any version of Access or any other way? I have access
97 and 2003 to work with as well as vb6 if I need it.

TIA

Matt
 
Matt,

There are sonme third party utilities that may help with this. For
example Total Access Alalyzer from www.fmsinc.com . You could also
write a VBA function to loop through the command button controls on the
form and write the value of their Click event properties to a table.
However, this will only give you part of the information you need. If
it was mine, I would probably do it manually, just look at the Click
event property of each command button in the design view of the form,
and track it through from there.
 
Steve-

Is there any documentation on the "Documenter" add-in? I can get the data I
want from it, but I have to filter it quite a bit to get just what I want.
I'd prefer to just grab those properties that I need, but I haven't
determined how to get at them yet. Do you have any code examples for doing
so? I've found this example in the archive that get the properties of a
form, but after I've determined that the control is a commandbutton, how do
I get at the properties for the click event?

Sub subExamineAllForms()
Dim db As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document
Dim frm As Form
Dim prp As DAO.Property
Dim ctl As Control

Set db = CurrentDb
Set cnt = db.Containers!Forms
cnt.Documents.Refresh

For Each doc In cnt.Documents
DoCmd.OpenForm doc.Name, acDesign
Set frm = Forms(doc.Name)
Debug.Print "*** Form [" & frm.Name & "]"
For Each prp In frm.Properties
With prp
Debug.Print .Name; " : Type=" & .Type & ", Value=" & .Value
End With
Next prp

'Code I've added here
for each ctl in frm.controls
if frm.controltype = acCommandButton then
'how do I access the properties to get the click event data?
end if
next ctl

DoCmd.Close acForm, frm.Name, acSaveNo
Next doc

Set frm = Nothing
Set cnt = Nothing
Set db = Nothing


End Sub

I would probably do it manually, just look at the Click event property of
each command button in the design view of the form, and track it through
from there.

There are over 100 mdb's, each with 1-20 forms and each form has from 2-40
buttons.. hence, my reasoning for wanting to do this programatically. ;)

TIA

Matt
 
Matt,

I *think* it's like this....

For Each ctl in frm.Controls
If ctl.ControlType = acCommandButton then
Debug.Print ctl.Properties("OnClick")
End If
Next ctl

As I said before, I think this will be of limited usefulness. You will
either get [Event Procedure] or the name of a macro, and you still then
have to go and see what the macro or the procedure does.
 
Back
Top