Hi everyone,
I am having a go at making a database for a charity and having trouble with ADO recordsets and subforms etc. For instance something very similar to this code has worked for me on another form, but this version is failing on the ‘Set Me.SbfMain.Form.Recordset = rstSub’ . I have confirmed that the recordset has records in it. The error code is 2455 and the message: “You entered an expression that was an invalid reference to the property recordset”
Here is the code
[indent]
Dim cmd As ADODB.Command
Dim rstSub As ADODB.Recordset
Dim prm As ADODB.Parameter
Dim prm2 As ADODB.Parameter
Set rstSub = New Recordset
rstSub.CursorLocation = adUseClient
rstSub.LockType = adLockBatchOptimistic
Set cmd = New Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = “qryLogFunderDates”
Set prm = cmd.CreateParameter
prm.Type = adDate
prm.Size = 25
cmd.Parameters.Append prm
cmd.Parameters(0).Value = CDate(“01/01/2001”) ‘ fromdate
Set prm2 = cmd.CreateParameter
prm2.Type = adDate
prm2.Size = 25
cmd.Parameters.Append prm2
cmd.Parameters(1).Value = CDate(“01/01/2004”) ‘ todate
rstSub.Open cmd
Set Me.SbfMain.Form.Recordset = rstSub
End Sub
[/indent]
The fact that the record set has records in it makes me think that I do not need to go into too much detail about the design. The subform starts off with a similar query in datasheet view and I am just trying to subset by date with the new query that has a couple of new fields in the WHERE clause.
Thank you for any assistance that anybody can offer.
Michael Beard
West Midlands Job Hunt : Job Hunter Blog : EarlsfieldGuide.co.uk