Datasheet's Recordset

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

Guest

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
 
You're overcomplicating. No recordset needed.

me.subformcontrolname.form.recordsource=strsql
 
Thanks. I tried it but my datasheet is blank. I have the correct number of
rows, but with no data. Thanks.
 
Huh? Just to check this... you have rows showing on the subform... but with
no data displayed in them?
 
Back
Top