Find/Replace

H

hackmn_g

Quick question for all you wise ones out there. Is there a way to do a
"find/replace" that looks in the PROPERTIES of each control item on a form?
Example: I created a form that looks at the March field in a table. I
copy/paste the form and need to change all property references from March to
April. I would want Access to scan each form and automatically
"find/replace". And not have to go into each control's properties to make
the change. Thanks, in advance, for the quick response!
 
J

Jason Rice

What properties are you looking to update?

You might try something like:

Dim ctrl As Control
Dim prp As Property
For Each ctrl In Me.Controls
For Each prp In ctrl.Properties
If prp.Value = "*March*" Then prp.Value = "something"
Next prp
Next ctrl

If "March" (and therefore "April") is at either the beginning, end, or a
predictable spot (i.e. starts with the fourth character) of the property
value then replacing the value will be easier. Otherwise you might have to
loop through the property value looking for the starting character of
"March".

Once you have found "March" in the value, you can replace it with "April" by
using something like prp.value="April" & mid(prp.value,6,Len(prp.value)-5)

HTH
 
Top