Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Looping through text boxes

Looping through text boxes

Looping through text boxes

I want to set the value of unbound text boxes on a form. The form is set up in a grid (Letters x Numbers). I want to loop through a few of the text boxes and place the required value in the correct text box. I thought I could concatenate the letter and number that corresponds to the grid to the base name of the text box.

For example:
Letter=65, Number=5.
strTextBox = "Me!txtCell" & Chr(Letter) & Number
Equals: Me!txtCellA5

Then I'd use strTextBox, and values from a query or table, to fill out the grid with data.

(Am I missing something fundemental about controls and forms?)

RE: Looping through text boxes

Your basic concept sounds OK, although why you're doing what you're doing escapes me.  Could you post the code snippet where you actually used strTextBox, and tell us what the problem was with what you tried?  Or didn't you get that far?

You need to refer to the control using this syntax:


Check out the help topic on Controls Collection to see what I mean.

I hope this helps.  Post again if you need more or if I missed your point.            


RE: Looping through text boxes

Thank you for your reply.
Unfortunately I had a family emergency that required me to miss work, so I was unable to respond to your post.

My problem was relatively simple. I wasn't properly formatting the string variable so that the form could recognize the variable as a control.

This is what I had:
strTextBox = "Me!txtCell" & Chr(Letter) & Number
Set ctlControl = strTextBox

And this is what worked:
strTextBox = "txtPrimer" & Chr(Letter) & Number
Set ctlControl = Me(strTextBox )

What I am trying to do is set up a user interface that displays data captured from an biochemistry instrument that performs experiments in a 16 x 24 grid. The users of the instrument are familiar with looking at the data in this grid format. So, even though it's a pain for me to design a form that looks like a grid, that's what I have to do.

I just can't get these scientist types to think in table, queries, and stepping through recordsets!

RE: Looping through text boxes

I guess you know you can add a subform on a main form.
The subform, in datasheet view will act like a grid. And also you have a main form to add controls and other things like a Print button

Also you can create macros and put them in a new tool bar at the top. So they can be viewing a table or whatever and still print a report or something.

DougP, MCP
 Ask me how Bar-codes can help you be more productive.

RE: Looping through text boxes

Unfortunately each cell in this grid is actually a unique record in the underlying table. In other words; depending on what the user wants to see, the value in each cell is actually one field for each of the 384 records that are viewed concurrently.

I've now got the form set up to switch between fields for each record and update the cells in the grid.

I'm sure I'll be posting more questions regarding this form.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close