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!

Updating Control Properties 2

Status
Not open for further replies.

jw5107

Technical User
Jan 20, 2004
294
US
I need to update a bunch of labels on a form...
I need to be able to take what the labels Caption is and updated that to the Tag properties.
Just a one time thing... Will never need to do it again & again. This will save me from doing it manually thru all the labels..
Below is what I am working with, and I doesn't do a thing...
Any suggestions..???
Thanks in advance..!!
jw5107
Private Sub Form_Load()
Dim frm As Form
Dim ctl As Control
Set frm = Forms!ProMap
Dim strTable As String
For Each ctl In frm.Controls
With ctl
If TypeOf ctl Is Label Then
strTable = ctl.Properties("Caption")
If strTable <> Null Then
ctl.Properties("Tag") = ctl.Properties("Caption")
End If
End If
End With
Next ctl
Set frm = Nothing
Set ctl = Nothing
End Sub
 
Hi!

Like this:

dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
ctl.Tag = ctl.Caption
End IF
Next ctl

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
jebry,
Thanks for the quick response!!!!
I have tried your example, but still get nothing...
I've tried - On Load, On Activate, On Open....
What am I missing..?
Any other suggestions..?
jw5107
 
Hi!

We both missed something. For the value in the Tag to stick the form needs to be in design view. Try this from another form:

Dim ctl As Control

DoCmd.OpenForm "YourForm", acDesign

For Each ctl In Forms!YourForm.Controls
If ctl.ControlType = acLabel Then
ctl.Tag = ctl.Caption
End If
next ctl

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
jebry,

That was it...!!
Just awesome...!!
Thank you!!!
Star for ya..!!

Thanks!!
jw5107
 
jebry,

I have been using your example and now need to do a similar thing for a report.
This is what I'm working with...

Private Sub Command1_Click()
Dim ctl As Control
DoCmd.OpenReport "HistoryProMap", acDesign
For Each ctl In Reports!HistoryProMap.Controls
If ctl.ControlType = acTextBox Then
ctl.ControlSource = "Forms!HistoryProMap!"
End If
Next ctl
End Sub

I need to change the control source of each textbox in the report from "Forms!ProMap!GTWY" - to - "Forms!HistoryProMap!GTWY"... There a several text boxes on this report. I only need to change everything to the left of the 2nd "!" in "Forms!ProMap!GTWY". I need to be able to keep the text box name for each control source change... Sure hope this makes sense..!!

Any suggestions..??
Thanks!!
jw5107
 
You may try this:
ctl.ControlSource = Replace(ctl.ControlSource, "Forms!ProMap!", "Forms!HistoryProMap!")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

Just Awesome...!!! Thank you very much..!!
Worked perfect..!!
Star for ya..!!

jw5107
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top