Forms Substitution Within A Loop

lhooker

Registered User.
Local time
Today, 10:30
Joined
Dec 30, 2005
Messages
423
How can I substitute "A1" in a "Forms" statement within a loop (as shown below) to move to the next textbox in a form.

Dim strAs As String
Dim Counter As Integer
Counter = 0

Do Until Counter = 30
Counter = Counter + 1
varX = DLookup("Question" & Counter, "Answers_Horizontal")
strAs = "[" & "A" & Counter & "]
"[Forms]![Form_Questions]!" & strAs & " = varX"
Loop


This is the original syntax ===> [Forms]![Form_Questions]![A1] = varX
I do not want create thirty (30) "Forms" statements.
 
Why not respond back to the original thread you made for this:


People had given advice.
 
Again. Dot notation not bang.
 
Why not respond back to the original thread you made for this:


People had given advice.
I did already . . . I used the EXCEL 'Transpose' feature.
 
maybe try:
Code:
Do Until Counter = 30
    Counter = Counter + 1
    varX = DLookup("Question" & Counter, "Answers_Horizontal")
    strAs = "A" & Counter
    Forms("Questions").Controls(strAs) = varX
Loop
 
Last edited:
maybe try:
Code:
Do Until Counter = 30
    Counter = Counter + 1
    varX = DLookup("Question" & Counter, "Answers_Horizontal")
    strAs = "A" & Counter
    Forms("Questions").Controls(strAs) = varX
Loop
This worked . . . Thanks ! ! !
 
No. Explained here.
Thread 'Bang Vs Dot, Me, and Default Properties' https://www.access-programmers.co.uk/forums/threads/bang-vs-dot-me-and-default-properties.327749/

Explains that only variable references can be used in Dot. @arnelgp is demoing using Dot. My previous thread did the same.
I used the EXCEL 'Transpose' featureand the code below to resolve my problems.

Do Until Counter = 30
Counter = Counter + 1
varX = DLookup("Question" & Counter, "Answers_Horizontal")
strAs = "A" & Counter
Forms("Questions").Controls(strAs) = varX
Loop
 
@lhooker, just for clarity: It appeared that you triple-posted. I deleted two of the three. I checked that they were, in fact, duplicates before doing so.
 
@lhooker, just for clarity: It appeared that you triple-posted. I deleted two of the three. I checked that they were, in fact, duplicates before doing so.
Thank you ! ! ! I wanted everyone to know that my problems were resolved. Someone mentioned in one of previous posts that I should let everyone know. Obviously, I made too many posts.
 

Users who are viewing this thread

Back
Top Bottom