I found @mwolfe02's Mike Wolfe's advice to do in-place Form requires without headaches or fuss. Cool. Looks easy enough, cuts down on extra coding required. Except...it doesn't work.
Every time, every form, no matter what, I get error 3251: "Operation is not supported for this type of Object". Every time. Doesn't matter how the Form is bound, whether via me.recordsource = "something"
, set me.recordset = somerecordset
, statically assigned in the Form Properties, etc.
Forms are set to Dynaset
, passthrough (when used) are opened as dbOpenDynaset
, etc.
I am able to use me.recordsetclone
just fine in these (in fact, that's what I'm doing now to get the rowid). What am I doing wrong? or is there something wrong? Or is this just not usable in practice with SQL Server as the source?
For reference, I'm using O365 Office 64 bit, Ver 16, and SQL Server as a backend, but some tables are loaded locally as temp tables.
[Edit] When setting the form's record source, I do it like this:
' (in the form open)
me.recordsource = SendSQLReturnData (SQLString) ' This works great, and I know the SQL functions.
(later in an OnPress from button:
me.recordset.requery ' <= Does not work.
' (SendSQLReturnData)
Public Function SendSQLReturnData(ByRef SQLString As String, _
Optional ByRef ReturnTable As String = PassthroughQuery, _
Optional DeleteExist As Boolean = False, _
Optional NoChange As Boolean = False) As String
'Sets up a passthrough query, hands back the name of the string via query.
Dim qdf As DAO.QueryDef
Dim rstReport As DAO.Recordset
Dim dB As DAO.Database
Set dB = CurrentDb
If DoesQryExist(ReturnTable) = False Then
'this handles the case where the table wasn't set up already either by accident or didn't need to be previously.
Set qdf = dB.CreateQueryDef(ReturnTable)
Else 'Assume the only other case for "Does it exist" is true, so don't bother checking
If NoChange = False Then
Set qdf = dB.QueryDefs(ReturnTable)
Else
GoTo Exit_Here
End If
End If
With qdf
.Connect = dB.TableDefs(BackEndKeyTbl).Connect
.SQL = SQLString
.ReturnsRecords = True
.OpenRecordset , dbOpenDynaset
End With
Exit_Here:
SendSQLReturnData = ReturnTable
qdf.Close ' Turning these on/off doesn't change result.
Set qdf = Nothing
Set dB = Nothing
End Function