dblankman
asked on
Assigning Subform record source from DAO query
I have the following code. Everything appears to work until this line:
Set Forms!TurtleMain!TurtleFee dingSub.Fo rm.RecordS ource = rsFeeding
I get an error '438' Object doesn't support this property or method.
Private Sub TurtleName_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object
Dim vTurtleID As Variant
Dim dbs As Database
Dim qdf As QueryDef
Dim strSQL As String
Dim rsFeeding As Object
Dim dbsql As Database
Set dbs = CurrentDb
' Set qdf = dbs.CreateQueryDef(strName , strSQL)
Set rs = Me.Recordset.Clone
rs.FindFirst "[TurtleId] = " & Str(Nz(Me![TurtleName], 0))
vTurtleID = Me![TurtleName]
Set dbsql = DBEngine.Workspaces(0).Ope nDatabase _
("", False, False, "ODBC;DRIVER=SQL Server Native Client 11.0;SERVER=WIN7DEV\SQLEXP RESS2012;U ID=David Blankman;Trusted_Connectio n=Yes;DATA BASE=Turtl esDB_beSQL ;")
strSQL = "spSubFeeding " & vTurtleID & " "
Set rsFeeding = dbsql.OpenRecordset(strSQL , dbOpenSnapshot, dbSQLPassThrough)
Set Forms!TurtleMain!TurtleFee dingSub.Fo rm.RecordS ource = rsFeeding
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
TurtleChosen
End Sub
Set Forms!TurtleMain!TurtleFee
I get an error '438' Object doesn't support this property or method.
Private Sub TurtleName_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object
Dim vTurtleID As Variant
Dim dbs As Database
Dim qdf As QueryDef
Dim strSQL As String
Dim rsFeeding As Object
Dim dbsql As Database
Set dbs = CurrentDb
' Set qdf = dbs.CreateQueryDef(strName
Set rs = Me.Recordset.Clone
rs.FindFirst "[TurtleId] = " & Str(Nz(Me![TurtleName], 0))
vTurtleID = Me![TurtleName]
Set dbsql = DBEngine.Workspaces(0).Ope
("", False, False, "ODBC;DRIVER=SQL Server Native Client 11.0;SERVER=WIN7DEV\SQLEXP
strSQL = "spSubFeeding " & vTurtleID & " "
Set rsFeeding = dbsql.OpenRecordset(strSQL
Set Forms!TurtleMain!TurtleFee
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
TurtleChosen
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also, after I run the code once, it won't let me run it with another TurtleID. I thought that, perhaps, I should close the connection. I tried doing a dbsql.Close, but that seems to close the recordset as well.
ASKER
Another thought that I had was defining the vTurtleID as a global variable and then assigning the recordset in the subform's onload event, although, I don't know if that would make any difference.
Looks like you've asked the followup question here:
https://www.experts-exchange.com/questions/28758859/Access-PassThrough-Query-not-returning-correct-number-of-records.html
So you should close this one out, as it seems your original question was answered.
https://www.experts-exchange.com/questions/28758859/Access-PassThrough-Query-not-returning-correct-number-of-records.html
So you should close this one out, as it seems your original question was answered.
ASKER