Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community

Form Recordset in DataSheet View

Copper Contributor

This is perplexing...


I am using ADO recordsets to bind my forms to an SQL backend, and this is all going very well.  I am sending commands up to SQL to run SP and getting records back all good.  


I am now wanting to load a view and thought gee why cant I use the same command tools to load the view...then thought hold on do I even need to?  Surely if I simply send the SELECT statement via command it will work...and it does...well kind of.


What I have is a table of jobs.  The jobs are nominally numbered 101,102, 103 and so on.  There is some other details as well but they are not relevant to the question or issue.


From Code I am performing the following:


Call cssFindExistingRecord("dbo.ActiveTemp", Me.Form)

'Which calls too
Public Sub cssFindExistingRecord(strTable As String, frm As Form)
'Using only the passed in table
'set the recrodset for the form
                Call cssLoad("SELECT * FROM " & strTable, frm)   '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
'Which calls too
Dim com As New ADODB.Command
    With com   

    Set .ActiveConnection = gcn
    .CommandType = adCmdText
    .CommandText = strCommand 'Runs sp with parameter
    Set frm.Recordset = .Execute   
    End With


Effectively the code is working as I am returning a record.


However that is the problem.  I am returning one record.


In Datasheet view, as I want to display this I am simply returning the 102 record 19 times, rather than 102, 103 etc to 121.


I don't see why this is?  I have looked online and can see examples on calling SP, but not using this method to simply return all the records.  The weird part to my mind is this method works to display records in datasheet views in subforms returned from SP.  So why not in this format?

0 Replies