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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing labelcaption from string 1

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
I have a db 'labels' with the names of all the labels that appear on my form and their caption (in several languages).
I now would like to change my form's labelcaptions with the names in my db. How can I select the label on my form that is equal to the labelname (string) in my db? This is what I already tryed, but the problem is to set the object = the db.labelname
Code:
  Dim obj As Label
  With rsLabel
    .MoveFirst
    For i = 1 To .RecordCount
      Set obj = !l_labelnaam
      obj.Caption = !L_LabelNL
      .MoveNext
    Next
  End With[\code]

Sfenx8-)
 
VB has a Controls collection, and you can reference individual items in that collection by index or - and this is the important bit for you - by name. e.g.

Collection("name")

So your code could be rewritten as:

[tt]With rsLabel
.MoveFirst
For i = 1 To .RecordCount
Controls(!labelname).Caption = !L_LabelNL
.MoveNext
Next
End With[/tt]
 
Thanks, strongm. That was just what I was looking for !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top