Results 1 to 5 of 5
  1. #1
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25

    a loop using vba to change control name


    How can the below control names be changed in a loop?

    I have one unbound form that will display 90 controls with 30 groups of controls having 3 controls (1 command, 1 text and 1 image) in each group. The only code difference between the 30 groups is a sequential number at the end of each control name. The table supplying the records is accessed using recordset.

    cmdText1.Visible = True
    txtRec1.Visible = True
    txtRec1.SetFocus
    txtRec1.Text = rs!AdminPK
    picThumb1.Visible = True
    picThumb1.Picture = rs![ObjectPhotoLink]
    picThumb1.HyperlinkAddress = rs![ObjectPhotoLink]

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This type of thing:

    Code:
    Dim x As Integer
    For x = 1 To 30
      Me("cmdText" & x).Visible = True
    Next x
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    Your code sample solved my problem. Thanks for the post. It will come in handy for some future mdbs

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    John Galt is the antongist to the sufficiating of the individual that is brought about by the narrow minded conformity collective of socialism

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

Similar Threads

  1. Replies: 4
    Last Post: 04-12-2012, 06:05 PM
  2. Copying entry form, change control source
    By Bdowns in forum Access
    Replies: 11
    Last Post: 02-06-2012, 05:39 PM
  3. how can change one control in whole rows
    By smahdih in forum Reports
    Replies: 5
    Last Post: 11-20-2011, 02:42 PM
  4. Change date from another control
    By NOTLguy in forum Forms
    Replies: 3
    Last Post: 11-20-2010, 11:24 AM
  5. Out of control loop in autoexec macro
    By accessnewbie in forum Programming
    Replies: 2
    Last Post: 08-19-2010, 04:31 PM

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