Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Unbound form Iterate a recordset with loop changing the textbox name from text1 to text2 to display information vba code

Posted on 2006-05-17
Medium Priority
Last Modified: 2012-06-27
I am using Access 2003.
I have an unbound form with a text boxes say text1 , text2, etc to text10   I need to iterate the recordset and change the recipient of the record each time from text1 to text2.  So I need build the name from text on the first loop to  text1 and so on. I can do this the long way but would like a neater way.
The reason I am using unbound is that there is a lot of data from many sources on the form and I would end up with lots of listboxes or sub -forms.  Thanks
Question by:Mike_Leggett
1 Comment
LVL 11

Accepted Solution

pootle_flump earned 1000 total points
ID: 16697621
Um...not sure if this is what you mean but:

For i = 0 to MyRecordset.Fields.Count -1

Me.Controls("text" & CStr(i +1)).Value = MyRecordset.Fields(i).Value

Next i

This writes the field values to each text box, incrementing as they go. If this is correct but populates the text boxes in the wrong order then you are better to name you textboxes appropriately to match the Fields.Name property and use that instead. Otherwise please could you restate your requirement.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Implementing simple internal controls in the Microsoft Access application.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

564 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