P
Peter
Hello,
I am having difficulty in setting my recordset to my subform which is setup
as a datasheet. My code is as follows:
'I've already declared my ADO objects and subform as class level variables.
'This procedure occurs from the main form's module.
Private Sub GetRecords()
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "SELECT strName, intNumber, lngAmount " & _
"FROM tblTest"
With rs
Set .ActiveConnection = cnn
.Source = strSQL
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockReadOnly
.Open
End With
Set sfrmTest.Recordset = rs
'Clean up.
Set cnn = Nothing
Set rs = Nothing
cnn.Close
rs.Close
End Sub
I usually get an empty datasheet even though my recordset does contain rows
of data. I've tried looping through the recordset, but that just gives me
repeated data from the recordset's last row. Any help would be appreciated.
Thanks,
Peter
I am having difficulty in setting my recordset to my subform which is setup
as a datasheet. My code is as follows:
'I've already declared my ADO objects and subform as class level variables.
'This procedure occurs from the main form's module.
Private Sub GetRecords()
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "SELECT strName, intNumber, lngAmount " & _
"FROM tblTest"
With rs
Set .ActiveConnection = cnn
.Source = strSQL
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockReadOnly
.Open
End With
Set sfrmTest.Recordset = rs
'Clean up.
Set cnn = Nothing
Set rs = Nothing
cnn.Close
rs.Close
End Sub
I usually get an empty datasheet even though my recordset does contain rows
of data. I've tried looping through the recordset, but that just gives me
repeated data from the recordset's last row. Any help would be appreciated.
Thanks,
Peter