Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Find/Replace to Change Property Value 1

Status
Not open for further replies.

jdspinelli

Programmer
Jul 9, 2010
20
US
Good Afternoon Everyone:

Can anyone out there tell me if there is a way to change Property Values using Find/Replace? For instance, I have about 10 text boxes named, "txt01", "txt02", "txt03", etc. I want to change them to "txtTest01", "txtTest02", "txtTest03". Is there a way to search through properties looking for "txt0"? This of course would be done without using the mouse to go control by control to select the controls.

Any help would be greatly appreciated.
Thanks,
 
There is no error handling in this code and my control names were a little different but you should be able to modify:
Code:
Sub ChangeControlNames()
    Dim frm As Form
    Dim strFrmName As String
    Dim ctl As Control
    Dim intCtlNum As Integer
    strFrmName = "frmChangeControlName"
    DoCmd.OpenForm strFrmName, acDesign
    Set frm = Forms(strFrmName)
    For intCtlNum = 1 To 10
        Set ctl = frm.Controls("text" & intCtlNum)
        ctl.Name = "TxtTest" & Format(intCtlNum, "00")
    Next
    DoCmd.Close acForm, strFrmName, acSaveYes
End Sub

Duane
Hook'D on Access
MS Access MVP
 
It should be a bit more generic and allow the user to specify a form, search control name, and replace control name much like a real search and replace. I typically don't like to hard-code values into a procedure.

Duane
Hook'D on Access
MS Access MVP
 
What you provided was just what I needed. I have a generic pop-up that will be a model for several other forms, so it was more for my maintenance than users. However, I can use this for other forms I have coming down the pike.

I used an XML package on my last contract that let you deal with form definitions in their native code. You could do massive (Ctrl + H) type replacements.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top