[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Is it possible to set MSAccess form object properties using variable substitution?

I have an MSAccess form that have 10 label and 10 text fields.  All fields are all set to invisible, and disabled, and depending on what selection the user selects, anywhere from 1 - 10 fields will become visible and the label captions will get set.  My question is this...depending on the selection, the label captions will be set to different things.  I want to set them using a loop.  The labels are called lblparm1, lblparm2, lblparm3, lblparm4, etc.   How can I set this using a loop or can I do that at all.  Can I do something like this:
for x = 1 to number of parms in query
strlabel = "lblparm" & cstr(x)
strlable.caption = .........
next i

I tried this but it doesn't work.  Is it possible?
1 Solution
Try this:

DIm I as Integer
For I = 1 to YourNumber
      Me.Controls("lblparm" & I).caption = "Label " & I
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I see what you want to do, but what is the field name in the query that contains the label information?

why not make it as control array?
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Carole ... are you wanting to set the label Captions from data in the query?

CaroleTSullivanAuthor Commented:
thank you everyone!
Glad to help.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now