Results 1 to 4 of 4
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    I need to change the caption in a label

    In a report, I have a label [Label49]. I need the caption to change according to a text field [FamilyMemberID]. It's a list of family members by their title: Children, Father, Mother, etc. I have tried this code, but it will label all of the labels according to the last entry.

    If FamilyMemberID = 1 Then
    Reports![rptFamily]!Label49.Caption = " CHILDREN"
    ElseIf FamilyMemberID = 2 Then
    Reports![rptFamily]!Label49.Caption = " FATHER"


    ElseIf FamilyMemberID = 3 Then
    Reports![rptFamily]!Label49.Caption = " MOTHER"
    ElseIf FamilyMemberID = 4 Then
    Reports![rptFamily]!Label49.Caption = " STEP-FATHER"
    ElseIf FamilyMemberID = 5 Then
    Reports![rptFamily]!Label49.Caption = " STEP-MOTHER"
    ElseIf FamilyMemberID = 6 Then
    Reports![rptFamily]!Label49.Caption = " FATHER-IN-LAW"
    ElseIf FamilyMemberID = 7 Then
    Reports![rptFamily]!Label49.Caption = " MOTHER-IN-LAW"
    ElseIf FamilyMemberID = 8 Then
    Reports![rptFamily]!Label49.Caption = " SIBLINGS"
    End If

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You can try it in the format or print event of the report section that contains the label. Or probably easier you can add it as a calculated field to the report's record source by either using a dLookup or best by adding the source table to the record source by joining on the FamiliyIdMember. Once you have the family member title in the record source open it in design view, right click on the label and click on Change To and choose textbox. Bind it to the new field and you're done.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I put it in the print event and it worked perfectly. Thanks a whole lot.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 05-08-2020, 10:38 AM
  2. Result of query into label.caption ?
    By SpookiePower in forum Queries
    Replies: 7
    Last Post: 12-17-2013, 01:56 PM
  3. Getting Value as label Caption
    By Naveen Marapaka in forum Forms
    Replies: 4
    Last Post: 09-18-2013, 12:22 AM
  4. Replies: 6
    Last Post: 01-16-2013, 12:12 PM
  5. Set Label.Caption to field of recordsource
    By ngruson in forum Forms
    Replies: 1
    Last Post: 08-11-2010, 09:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums