Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Oct 2002
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use form (Change caption)

    I use Forms![frmCombined].[Unit1].Caption = [cboPickAUnit] to change the caption of a tab, but want to change the code so Unit1 is actually a concatenation of "Unit" and the name of the form (1, 2, 3, etc.) [actually part of the name of the form Unit1, Unit2, etc] . Is there a way to do this?

    Thanks,

    Howard

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Use form (Change caption)

    Yes, using the Controls collection. You can use Controls("controlname") to refer to a control by its name as a string, and this string can be a variable or an expression.

    If lngUnit is a numeric variable holding the unit number (1, 2, 3, etc.), you can use
    Forms!frmCombined.Controls("Unit" & lngUnit)

    Or if strForm is a string variable holding the name Unit1, Unit2, ..., you can use
    Forms!frmCombined.Controls(strForm)

  4. #3
    Lounger
    Join Date
    Oct 2002
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use form (Change caption)

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •