Retrieve fields with FOR statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I've a table (tblMasterList_RV) with 60 fields and the field names are named
Field1, Field2, ..., Field60. I'm trying to write a loop (using VB6) to
retrieve the fields into a series of text boxes, but only the text
"grstMasterList_RV![Field1]" is displayed. Is there a correct way without
changing the field names?

Private Sub LoadRecord()
Dim pstrSQL As String
Dim pstrString As String
Dim pintIndex As Integer

pintIndex = 0
pstrSQL = "Select * from tblMasterList_RV ORDER BY Field2"
Set grstMasterList_RV = gdb.OpenRecordset(pstrSQL)
grstMasterList_RV.MoveFirst

For pintIndex = 0 To 59
pstrString = "Field" & pintIndex + 1
txtField(pintIndex).Text = "grstMasterList_RV![Field" & pstrString &
"]"
Next pintIndex

End Sub
 
Back
Top