Re: Access CommandButton "On Click" property

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Matt Williamson (ih8spam_at_spamsux.org)
Date: 03/22/05


Date: Tue, 22 Mar 2005 15:38:33 -0500

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

"Steve Schapel" <schapel@mvps.org.ns> wrote in message
news:ehmfmxxLFHA.4092@tk2msftngp13.phx.gbl...
> 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 Schapel, Microsoft Access MVP
>
>
> Matt Williamson wrote:
>> 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



Relevant Pages

  • RE: Run a Stored Procedure from Excel
    ... You also want to find out if you have a rsDW variable defined. ... Your code had a semicolon between the 2nd command and the ... Dim cnnDW As ADODB.Connection ... Set cnnDW = New ADODB.Connection ...
    (microsoft.public.excel.programming)
  • RE: Run a Stored Procedure from Excel
    ... "You also want to find out if you have a rsDW variable defined. ... Your code had a semicolon between the 2nd command and the ... Dim cnnDW As ADODB.Connection ... Set cnnDW = New ADODB.Connection ...
    (microsoft.public.excel.programming)
  • RE: Open Access 2003 or 2007 from Excel
    ... 'EXAMPLE OF ACCESS COMMAND TO CONTROL FORMS ... 'Dim dbMain As ADODB.Connection ... 'Dim dbMain As ADODB.Connection 'compile error: ... new computers that now have VISTA as the OS. ...
    (microsoft.public.excel.programming)
  • Re: Multiple table in dataset query
    ... If a row is marked as Modified, it will run your query defined in the ... Update Command object. ... Dim UpdateStaffCmd As New OleDb.OleDbCommand ... Private Sub frmStaff_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.adonet)
  • Tool to get MCP ODT at Windows CMD prompt
    ... You basically send a series of ODT commands of your choosing, once, or in a loop, and get the output right in the command ... Dim sHostname ... Sub WriteIt ... WriteIt "" ...
    (comp.sys.unisys)