marieves
01-26-2001, 05:40 AM
I am trying to populate a subform from the results of a stored procedure using the code below.
This loops through the recordset, when it populates the subform and only populates the LAST Record in the recordset - and the subform has only one record - despite teh recordset containing many records.
Any suggestions as how I can make the subform (Datasheet) populate all of the recordset?? ie: make the subform add a new record in code, before the form loads.
Thanks in advance.
---------------------------
Private Sub Form_Load()
Dim cmd As New ADODB.Command
Dim parmExecSearchID As New ADODB.Parameter
Dim conn As New ADODB.Connection
Dim sql As String
Dim rst As New ADODB.Recordset
Dim intExecSearchID As Long
intExecSearchID = 0 + Me.Parent.OpenArgs
conn.ConnectionString = strCnn
conn.Open
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "BackOfficeFilterResults"
cmd.ActiveConnection = conn
Set parmExecSearchID = New ADODB.Parameter
parmExecSearchID.Type = adInteger
parmExecSearchID.Size = 4
parmExecSearchID.Direction = adParamInput
parmExecSearchID.Value = intExecSearchID
cmd.Parameters.Append parmExecSearchID
Set rst = cmd.Execute()
' ****
Do While Not rst.EOF
Me.Current_Employment = rst!CurrentJobTitle & ""
'all other fields.......
rst.MoveNext
Loop
End Sub
This loops through the recordset, when it populates the subform and only populates the LAST Record in the recordset - and the subform has only one record - despite teh recordset containing many records.
Any suggestions as how I can make the subform (Datasheet) populate all of the recordset?? ie: make the subform add a new record in code, before the form loads.
Thanks in advance.
---------------------------
Private Sub Form_Load()
Dim cmd As New ADODB.Command
Dim parmExecSearchID As New ADODB.Parameter
Dim conn As New ADODB.Connection
Dim sql As String
Dim rst As New ADODB.Recordset
Dim intExecSearchID As Long
intExecSearchID = 0 + Me.Parent.OpenArgs
conn.ConnectionString = strCnn
conn.Open
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "BackOfficeFilterResults"
cmd.ActiveConnection = conn
Set parmExecSearchID = New ADODB.Parameter
parmExecSearchID.Type = adInteger
parmExecSearchID.Size = 4
parmExecSearchID.Direction = adParamInput
parmExecSearchID.Value = intExecSearchID
cmd.Parameters.Append parmExecSearchID
Set rst = cmd.Execute()
' ****
Do While Not rst.EOF
Me.Current_Employment = rst!CurrentJobTitle & ""
'all other fields.......
rst.MoveNext
Loop
End Sub