Solved

I need to refer to a text field by using a variable for its name.

Posted on 2011-09-10
4
214 Views
Last Modified: 2012-05-12
Hello Experts!

I think this should be an easy question.  I've done it before but don't remember how!

I have a form that has space for 20 images.
The image "boxes" are named imgbox01, imgbox02, imgbox03 and so forth

The images that I want to display are in the array arrImage(20)

My code loops through each image in arrImages() from n=1 to 20

when I decide to display an image in a specific box, for example, imgbox2, i need to programmatically refer to this image box.

Here is an sample of my code:
'Put the image stored in location nn in the array in the imgbox specified by n
For n=1 to 20
  if <some condtion> then
     Forms!frmPhotoAlbum.Image4.Picture = arrImage(nn)
next

Only, I do not want to hard code 4 into this line, as sometimes it will go into possition 6, or whatever the value of n currently is

So, how do I incoporate the value of n into the name of the imagebox?
in other words, if n=2 how do I code so that I can replace the 4 with the value for n?
Forms!frmPhotoAlbum.Image4.Picture =arrImage(2)

0
Comment
Question by:pcalabria
  • 2
4 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 36516377


use this format

Forms("frmPhotoAlbum")("Image" & n).Picture =arrImage(2)
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36516380


use this format

Forms("frmPhotoAlbum")("Image" & n).Picture =arrImage(n)
0
 
LVL 44

Expert Comment

by:GRayL
ID: 36516870
Where do you keep the number of the image in the arrray?  I assume the array element is a string, structured along the lines of:

c:\data\images\myPic.jpg
0
 

Author Closing Comment

by:pcalabria
ID: 36518820
Perfect!

Thanks CAP!!!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now