getrow on single record

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

getrow on single record

Post by sal21 »

i use, to store in array all records from query:

Dim strDBRows() As Variant
Erase strDBRows()
strDBRows = RS.GetRows()
RS.Close
Set RS = Nothing
...

is possible to store into the array only all values from a single field, for example field F1

????

User avatar
HansV
Administrator
Posts: 78626
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: getrow on single record

Post by HansV »

You should make the recordset return only the single field F1:

Dim strSQL As String
strSQL = "SELECT F1 FROM MyTable"
RS.Open Source:=strSQL, ActiveConnection:=...
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: getrow on single record

Post by sal21 »

HansV wrote:You should make the recordset return only the single field F1:

Dim strSQL As String
strSQL = "SELECT F1 FROM MyTable"
RS.Open Source:=strSQL, ActiveConnection:=...
no...
my sql contain various fileds (i use from other loop.)

but in this case i need to store fron the varius values extracted from query and store it into array only the value of F1.

example of actual sql:

sql="select f1, f2,...f7 from ...."

User avatar
HansV
Administrator
Posts: 78626
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: getrow on single record

Post by HansV »

You can use

strDBRows = RS.GetRows(Fields:="F1")
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: getrow on single record

Post by sal21 »

HansV wrote:You can use

strDBRows = RS.GetRows(Fields:="F1")

ops!
In need to store in array, two Fields F1 and F2

User avatar
HansV
Administrator
Posts: 78626
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: getrow on single record

Post by HansV »

strDBRows = RS.GetRows(Fields:=Array("F1","F2"))
Best wishes,
Hans