hi,
i have a number (about 100) of labels that i want to automatically update from a table when i load a form.
as there are a lot of labels i don't want to have to hard code each individual one.
the labels are named lbl1, lbl2, etc...
the code im using to update my form on load is:
For i = 1 To count
'select each date from the lblCaptions table according to the label name
sqlStr = "SELECT DateStamp FROM lblCaptions WHERE lblName = 'lbl" & i & "';"
'open recordset
Set rs = db.OpenRecordset(sqlStr, dbOpenSnapshot, dbForwardOnly)
data = rs.GetRows(1000)
labelName = "lbl" & i
rsBoundry = UBound(data, 2) + 1
For j = 0 To rsBoundry - 1
'display the date corresponding to the label on the form
Forms("Monthly Reports (Gavin)").labelName.Caption = data(0, j)
Next
Next
the problem is the Forms("Monthly Reports (Gavin)").labelName.Caption = data(0, j), i get an error when i try to use the string variable labelName, this works fine if i replace it with lbl1 - but then i will have to do this for the hundred or so labels that i have on the form
thanks in advance
gavin