HI,
I asked this several days ago and still don't have a
solution. Maybe there isn't one.
I have a form with about 25 fields on it all of which
comes from one table. Five of the fileds can be used for
whatever the user wants and I call
them "special1", "special2", etc. I want the user to be
able to change the labels on the form for those 5 fields.
For example if they want to store Locker Numbers in
special1 the label on the form would say "Locker Number".
Is this possible? Can the 5 labels be stored in a table
and be used as the "record source" in a text box or is
there some other way this can be done? Everything I've
tried has not worked. Of course, I don't want the user to
go into design view.
Thanks,
Phil
This is re-assembled from several previous posts of mine.
I think it should work as written.
Labels bound to a text control do not have an Event property.
If your labels for these 5 controls are bound to their control, cut
them. Then paste them back into the detail section.
They should now have an Event property.
Labels placed on the form directly from the tool box do have an Event
property and nothing else need be done.
*** Name these labels with a number at the end., i.e. Label1, Label2,
Label3, etc. They should be consecutive (but they don't have to start
at 1).
You only need to do this for those labels that you want the user to be
able to change. ***
Add a new table to the database.
FieldName Datatype
LabelName Text Indexed (No Duplicates) PrimeKey
CaptionText Text
Name this table "tblCaptions"
Have the LabelName field store the NAME of the label (i.e. Label1,
Label2, Label3, etc.).
For now, enter the starting names of the labels in the LabelName
field, and their starting captions in the CaptionText field.
(this need only be done once.)
Now the table has data like:
CaptionText LabelName
Transportation Label1
Employment Label2
Sales Label3
etc.
Next add a new Sub Procedure within the Form's code sheet:
' Watch the line breaks on the longer lines.
Public Sub NewCaptions(lblName As String)
Dim strNewLabel As String
strNewLabel = InputBox("New Text", "Caption change")
Dim L As Label
Set L = Me(lblName)
L.Caption = strNewLabel
DoCmd.SetWarnings False
DoCmd.RunSQL "Update tblCaptions Set CaptionText = '" &
strNewLabel & "' Where LabelName = '" & L.Name & "';"
DoCmd.SetWarnings True
End Sub
============
Then code EACH label's Double-click event:
NewCaptions "Label1"
Note.. Change the Label1 above to whatever the label's name is.
Make sure it's within Quotation marks.
To return the latest captions when opening the form:
Code the Form's Load event:
Dim intX As Integer
Dim L As Label
For intX = 1 To DCount("*", "tblCaptions")
Set L = Me("Label" & intX)
L.Caption = DLookup("[CaptionText]", "tblSaveCaption",
"[LabelName] = '" & L.Name & "'")
Next intX
========
' Note If the LabelNames starts at a different number, change the
above code as needed, i.e. For intX = 8 to DCount(etc.) + 7
I think that should be all you need.