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. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 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)

  3. #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
  •