Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Processing 1

Status
Not open for further replies.

accessisnew

Technical User
May 25, 2006
15
US
I have a form with rows of data that I want to process one field at a time. When I built the form each field is assigned a sequential "Textxx" number e.g. Text1, Text2, Text3, etc. The form and fields are not bound and the form is populated by running a VBA module that retrieves the data, populates the fields, and after displaying the form, there will be updates performed based on user changes.

I can process each field by using the "Textxx" name which means using the same code and changing the "xx" resulting in long repetitive code. I really want to use a loop to process all the fields so I don't have a lot of repeated code (I know, cut and paste, but I want to be more efficient).

A sample of the form layout:

Text1 Text2 Text3
Text4 Text5 Text6
Text7 Text8 Text9
Text10 ...
.
.
.

I've tried Using "Text" & 1 and it doesn't work. I read two other threads that, to me, refer to a similiar situation but nothing I've tried works.

Help please.
 
A starting point:
For i = 1 To 10
MsgBox "Text" & i & "=" & Me("Text" & i)
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, but I tried that and receive an error using "me".
 
Your code is not in the form's module ?
MsgBox "Text" & i & "=" & Forms![name of mainform].Controls("Text" & i)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Correct my code is not in the form module. I is a standalone module.
 
So you pass the Form object as parameter ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No, I don't pass the form object as a parameter. I run the module and open the form in the code with a DoCmd.OpenForm.

Is my technique incorrect for Access? My background is mainframe, Cobol, CICS and we would define the first line on the form and then use an OCCURS clause to repeat it on the form giving one name to each field and then use each name with a subscript for each line.
 
Access VBA lacks ControlArray ...
BTW, did you try my suggestion timestamped 21 Jun 06 14:17 ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry that I missed your suggestion in the earlier post because that is the answer. Thank you so much for working with me and your patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top