Change Function name in event in form design (1 Viewer)

tonez90

Registered User.
Local time
Tomorrow, 08:06
Joined
Sep 18, 2008
Messages
41
Hi I have allocated a function (event) to a control on a form (i.e. =PopupCalendar([Screen].[ActiveControl]) on the event 'On Dbl Click').

The issue is that the database is quite large and the function is used on a lot of forms. I want to rename the function to say fn_popupCalendar to make it a bit more readable.

So I am wondering if there a module or similar I could use to change the event name on each form property without having to open in design mode and physically change for every occurrence?

Regards
Tony
 

nhorton79

Registered User.
Local time
Tomorrow, 10:36
Joined
Aug 17, 2015
Messages
147
There are other special addons and tools that allow you to do things like this among other things.

However the easiest way is to use Find & Replace. It should be under the Edit menu in the VBA editor. Or you can use Ctrl + F to access the Find pop up and then click the Replace tab.

Set the existing function name in the find box and the new function name in the Replace box.
Then select the Current Project (I think it’s what it’s called) radio button, instead of Current Module.

You can then either click Replace All, or try clicking Find Next and then if it matches the function name then click Replace (a bit slower, but allows you check you’re replacing the right entries).


Sent from my iPhone using Tapatalk
 

Dreamweaver

Well-known member
Local time
Today, 21:36
Joined
Nov 28, 2005
Messages
2,466
Don't think Find/replace will work on all forms contol properties as it looks like that's where the call seems to be you would have to change the function name in the module then open each form and edit the property this can be done in code but i susspect it is above your lvl im just off to work so maybe somebody else will be able to help you.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:36
Joined
May 7, 2009
Messages
19,169
rename first your function.
on a module paste this and run:
Code:
Public Function fnAllForm()
    Dim frm As AccessObject
    Dim ctl As Control
    Dim thisForm As Form
    For Each frm In CurrentProject.AllForms
        DoCmd.OpenForm frm.Name, acDesign, , , , acHidden
        Set thisform = Forms(frm.Name)
        For Each ctl In thisform
            If TypeOf ctl Is TextBox Then
                If ctl.ControlSource = "=PopupCalendar([Screen].[ActiveControl])" Then
                    ctl.ControlSource = "=fn_popupCalendar([Screen].[ActiveControl])"
                End If
            End If
        Next
        DoCmd.Close acForm, frm.Name, acSaveYes
    Next
End Function
 

nhorton79

Registered User.
Local time
Tomorrow, 10:36
Joined
Aug 17, 2015
Messages
147
Whoops sorry didn’t see control source..,


Sent from my iPhone using Tapatalk
 

Users who are viewing this thread

Top Bottom