Right now, I have a database, with a SQL Server backend, and a MS Access frontend. On one form, my users are experiencing slow load times for it to display. The form essentially looks up to see who the user is (based on their login ID, this part works), sees their access rights (readonly, v. update, etc.; this also works), and then pulls the projects they are allowed to see based on their access rights (this is the part I believe is running slow).
To make this form load faster, I feel that moving the last part, the part that pulls the projects they are allowed to see, to an SSMS Stored Procedure should make the form faster to load.
I have the stored procedure written, in SSMS, and I have the code on the 'Form Load' event that calls the stored procedure. The issue I am facing is having the results of the stored procedure become the Recordsource of the form. I've tried Me.RecordSource, but that doesn't seem to be working. Below is a copy of the code that calls the Stored Procedure:
This is different than having code to call an SP, because I already have the code to call it, however, I need the results of the SP to be the recordsource of an MS Access form.
Any help, or ideas will be appreciated! (e.g. I thought of trying to use a temp table to serve as the recordsource...)
Dim rs1 As ADODB.Recordset
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
cn.ConnectionString = "DRIVER=SQL Server;SERVER=SERVERNAME;APP=Microsoft Office XP;WSID=MYCOMPUTER;DATABASE=dbname;Trusted_Connection=Yes;"
cn.Open
Set cmd = New ADODB.Command
Set rs1 = New ADODB.Recordset
With cmd
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "dbo.ProcProjectSelection"
Set prm = .CreateParameter("@xID", adVarChar, adParamInput, 10, Me.txtNetworkID)
.Parameters.Append prm
End With
If I put: Set Me.RecordSource = rs1 Before the "end with", I get an Error Message saying "Invalid Use of Property"