In my Access 2016 report I have 10 controls named txt1 to txt10 and I want to populate them from records in a table. Is there any way to increment the control name in my loop based on my counter?
Something like this. Obviously Me.txt(counter) is not an array but the best representation I can give for what I want to do.
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim counter as integer
Set db=CurrentDatabase
Set rs=db.OpenRecordSet("SELECT * FROM table WHERE variable = " & something)
If Not rs.EOF Then
rs.MoveFirst
counter = 1
Do Until rs.EOF
Me.txt(counter) = rs.Fields("field1")
counter = counter + 1
rs.MoveNext
Loop
End If
Thanks!
使用以下内容:
Me("txt" & counter) = rs.Fields("field1")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.