setting a unbound subform to a recordource in a adodb array

I have a main form
I have a subform on a tabctrl27   page28
child31 = subform name

Once i get the data into an array
rcarray = rst.GetRows

I need to assign the subform the array and display the data ?

is this possible ?

Thanks
fordraiders
LVL 3
FordraidersAsked:
Who is Participating?
 
Eric ShermanConnect With a Mentor Accountant/DeveloperCommented:
<<<Once i get the data into an array
rcarray = rst.GetRows>>>

Use a Query/SQL to change the Record Source of your sub form.

ET
0
 
FordraidersAuthor Commented:
I need the array to supply the subform
0
 
Eric ShermanAccountant/DeveloperCommented:
As far as I can tell ... In Access, a From Object's Record Source is either a Table Object or Query Object.

ET
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can use the Recordset as your data source, without putting it into an Array:

Me.Recordset = rst

Or if you're doing this from the main form:

Me.SubformCONTROL.Form.Recordset = rst
0
 
PatHartmanCommented:
A recordset IS an array.  So if you use bound subforms, you don't need to do any coding to handle multiple records.  Why not tell us what you are trying to do that a bound subform won't do for you?
0
 
FordraidersAuthor Commented:
Pat.
running a stored procedure from sql server via vba:
' CONNECTIONS FOR SQL SERVER
strConnect = "provider=sqloledb;Server=PRMD.xxxxx.com;Database=Quote;Uid=xxxxx;Pwd=axxx;"
' Instantiate the connection object
Set cnn = New ADODB.Connection
' Open the connection based on the strConnect connect string arguments
cnn.Open strConnect
' Instantiate the command object
Set cmd = New ADODB.Command
' Assign the connection and set applicable properties
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_DefaultSearch"
' Instantiate the recordset object by using the return value
' of the command's Execute method. Supply the parameters by
' packing them into a variant array
cmd.Parameters.Append cmd.CreateParameter("@Token", adVarChar, adParamInput, 10, S_TOKEN)
Set rst = cmd.Execute()

so once i have the rst  I was hoping to put into an unbound subform.
I have to rerun this query for each search..


fordraiders
0
 
FordraidersAuthor Commented:
running this search from a command button.
0
 
PatHartmanCommented:
Why are you using a stored procedure rather than an Access or pass-through query?  Why are you using an unbound form?  Access is a rapid application development tool.  The heart of what makes it "rapid" is bound forms.  You need to think long and hard before deviating from that and if you decide that you absolutely must use unbound forms, then consider using some platform other than Access because you are incurring all the problems of deploying an Access solution without getting the benefits of RAD.
0
 
FordraidersAuthor Commented:
Pat , i switched to a pass through query. And bound the subform to that pass through.
0
 
PatHartmanConnect With a Mentor Commented:
You will be much happier with that solution and it is much less work.  The form is not updateable though.  If that is a problem, replace the pass-through query with a normal Access query against a linked table or view.

Access attempts to make every query a pass-trough query so if your query selects 100 records out of a million, Access sends the query to the server and the server returns 100 records.  It does NOT return the entire table.  You can of course defeat Access by doing things that prevent Access from sending the query to the server.  In that case, Access will send an unqualified query to select all the rows and then finish the process locally.  Things like heterogeneous joins and VBA functions in a where clause cannot be sent to the server and so must be handled locally.  As long as you understand the process, you can control it.  I find that I rarely need pass-through queries for bound forms although sometimes views are helpful.

Make sure you are making decisions on how the app is structured based on an understanding of how Access actually works.
0
 
Eric ShermanAccountant/DeveloperCommented:
ITA with PatHartman's last comments and is why I originally suggested using a Query or Table object.

ET
0
 
FordraidersAuthor Commented:
Thanks guys for the direction.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.