0

greetings for all access experts in this forum

I got problems when trying to concat between my text box name with string.

In my form there are 10 textboxs named : Student1, Student2, Student3...Student10

I tried to get value from each textbox

This is my code :

Dim a as string
a = 1
do until a = 2
MsgBox (Me.Controls("Student"&a).Value)
loop

It's not working. No error also.

Any help would be appreciated.

Many thanks.

2
  • 1
    You've declared a as a string, then attempted to use it as an integer in a loop, and then you never increment it. Have you stepped through your code? Commented Jun 8, 2013 at 12:37
  • Ups sorry, I paste wrong code. Dim a as string a = 1 do until a = 2 MsgBox (Me.Controls("Student"&a).Value) a = a+1 loop Yes, you're right it should be Integer. It works now. Thank you so much Commented Jun 8, 2013 at 13:05

1 Answer 1

1

Try something more like this:

Dim i As Integer
For i = 1 To 3
    MsgBox Nz(Me.Controls("Student" & i).Value, "")
Next
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Gord, I've tried it and it's works! I've been searching it all day. Thank you so much for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.