[AccessD] Programmaticly fill control events

t tom ttom at accessyourdata.com
Thu Feb 20 16:10:00 CST 2003


Hi Marcel and Group

I was fooling around with something similar.( I got this code from Beginnig
Access 97 VBA Programming book )
Change the code below .

You should be able to save the form names to a table.
Sub testCon()
Dim db As Database
Dim ContainerTest As Container
Dim DocumentTest As Document
Set db = CurrentDb()
For Each ContainerTest In db.Containers
    Debug.Print "Container:  "; ContainerTest.Name
    For Each DocumentTest In ContainerTest.Documents
        Debug.Print "      Document:  "; DocumentTest.Name
    Next
Next
End Sub

Then you can test each control on the form after you open it with:-

( if ctlControl .ControlType = acCommandButton then ..............)

Sub testForm()
Dim frmCurrent As Form
Dim ctlControl As Control

For Each frmCurrent In Forms
    Debug.Print "Form Name: "; frmCurrent.Name
    For Each ctlControl In frmCurrent
        Debug.Print "       Contol Name:  "; ctlControl.Name
    Next
Next
End Sub

Look in HELP under "ControlType Property"  and look at the example

HTH
Tomt


----- Original Message -----
From: "Patricio Galleguillos" <pgalleguillos at plus.cl>
To: <accessd at databaseadvisors.com>
Sent: Thursday, February 20, 2003 12:24 PM
Subject: RE: [AccessD] Programmaticly fill control events


> Hi Marcel and Group
>
> Unless someone comes with a 'ready made' solution the steps for doing it
> can be:
>
> - Generate a list with the names of the forms and the names of the
> controls to be 'evented'
> - for each form get the code module (VBIDE)
> - for each control in the form append the appropriate event handler(s)
> in the code module. (easy at the end of the code module, checking that
> it is not already written. It may have code for doing something else)
>
> If you modify code programmatically inside a sub, it works but I'm not
> sure what happens if you add a complete sub.
>
> I have some code that uses VBIDE to show all names of functions and subs
> in a project (always forget where I put them...), if it can be useful
> mail me off line. (not very much comments and all of them in spanish)
>
> Maybe this is not very difficult for the gurus but I don't think it is
> an easy task for the rest of us.
>
> Saludos cordiales,
> Patricio Galleguillos B.
>
> pgalleguillos at plus.cl
>
>
>
> -----Mensaje original-----
> De: accessd-admin at databaseadvisors.com
> [mailto:accessd-admin at databaseadvisors.com] En nombre de Marcel Vreuls
> Enviado el: jueves, 20 de febrero de 2003 9:24
> Para: accessd at databaseadvisors.com
> Asunto: [AccessD] Programmaticly fill control events
>
> Dear group,
>
> I have added some more color to my app. This means the control where the
> cursor is at that time is being highlighted. It works like a charm. I
> have
> found this solution in the archives of this list.
>
> But I have more than 200 forms en I gues more that 2500 controls. Is
> there a
> way through code to add an event to a control. So open the form en check
> all
> controls (that's what I know) but I don not know how to add an event and
> add
> some code through it. Anyone?
>
> Thanks Marcel
>
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com





More information about the AccessD mailing list