C
confused
I have a form that I want to set the record source on the fly based on the
selection that the user makes on another form. Once the form opens, than I
want to set the control sources of text boxes based on the record source of
the form. Both of my loops are working. Below is the code that I have on
the form's on load event.
RecSource = Me.RecordSource
' Set database variable to current database.
Set dbsCurrentDB = CurrentDb
' Open Recordset object.
Set rstForm = dbsCurrentDB.OpenRecordset(RecSource)
' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstForm.Fields.Count
rstForm.MoveFirst
Do
I = 1
For I = 1 To intColumnCount
Me("txt" + Format(I)) = rstForm(I - 1)
Next I
rstForm.MoveNext
Loop Until rstForm.EOF
rstForm.Close
But when the form opens, the data that is showing is the data of the last
record.
What am I missing in my code?
Many thanks!
selection that the user makes on another form. Once the form opens, than I
want to set the control sources of text boxes based on the record source of
the form. Both of my loops are working. Below is the code that I have on
the form's on load event.
RecSource = Me.RecordSource
' Set database variable to current database.
Set dbsCurrentDB = CurrentDb
' Open Recordset object.
Set rstForm = dbsCurrentDB.OpenRecordset(RecSource)
' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstForm.Fields.Count
rstForm.MoveFirst
Do
I = 1
For I = 1 To intColumnCount
Me("txt" + Format(I)) = rstForm(I - 1)
Next I
rstForm.MoveNext
Loop Until rstForm.EOF
rstForm.Close
But when the form opens, the data that is showing is the data of the last
record.
What am I missing in my code?
Many thanks!