Solved

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

Posted on 2011-09-10
4
216 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 36516377


use this format

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

Expert Comment

by:Rey Obrero (Capricorn1)
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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