infomania
Programmer
- Oct 27, 2002
- 148
I am trying to populate an unbound form with the results of a query using the following code:
Private Sub Form_Open(Cancel As Integer)
' set initial values
Dim stSQL As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
stSQL = "SELECT * FROM qselClosingTransfers"
rs.Open stSQL, conn, adOpenStatic
Do While Not rs.EOF
Me.RESD_NAME = rs!RESD_NAME
Me.RESD_NUMBER = rs!RESD_NUMBER
Me.UNIT_NUMBER = rs!UNIT_NUMBER
Me.MOVE_IN_DATE = rs!MOVE_IN_DATE
Me.AMT_IN_ENTRY_FEE = rs!AMT_IN_ENTRY_FEE
Me.AMT_OWED_FOR_CUST_CHG = rs!AMT_OWED_FOR_CUST_CHG
Me.FINAL_BAL = rs!FINAL_BAL
Me.CLOSING_BATCHED = rs!CLOSING_BATCHED
rs.MoveNext
Loop
rs.Close
conn.Close
End Sub
What I get is only the last record in the record set. Is there a way to do this where all the rows of the record set will show up in the form?
thanks, in advance
infomania
Private Sub Form_Open(Cancel As Integer)
' set initial values
Dim stSQL As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = CurrentProject.Connection
Set rs = New ADODB.Recordset
stSQL = "SELECT * FROM qselClosingTransfers"
rs.Open stSQL, conn, adOpenStatic
Do While Not rs.EOF
Me.RESD_NAME = rs!RESD_NAME
Me.RESD_NUMBER = rs!RESD_NUMBER
Me.UNIT_NUMBER = rs!UNIT_NUMBER
Me.MOVE_IN_DATE = rs!MOVE_IN_DATE
Me.AMT_IN_ENTRY_FEE = rs!AMT_IN_ENTRY_FEE
Me.AMT_OWED_FOR_CUST_CHG = rs!AMT_OWED_FOR_CUST_CHG
Me.FINAL_BAL = rs!FINAL_BAL
Me.CLOSING_BATCHED = rs!CLOSING_BATCHED
rs.MoveNext
Loop
rs.Close
conn.Close
End Sub
What I get is only the last record in the record set. Is there a way to do this where all the rows of the record set will show up in the form?
thanks, in advance
infomania