parmarparveen
asked on
How to store a query result in a variable?
Hi,
I have created a query which retuarns a single string value in result. I want to store this resulted string value in a variable for further comparison with other variables. Please help me with syntax.
Thanks
Praveen Parmar
I have created a query which retuarns a single string value in result. I want to store this resulted string value in a variable for further comparison with other variables. Please help me with syntax.
Thanks
Praveen Parmar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, how about running a test in a loop of 100K times to see ?
mx
mx
Did that already. You lose by a factor of 2:1 ;-)
Cool. That's a good trick!
What about MP's scheme, similar to yours but with the extra line of code. Run that.
mx
What about MP's scheme, similar to yours but with the extra line of code. Run that.
mx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Public Function mCheckTime()
Dim x As Long, n As Long, ID
Dim ts
x = 50000
ts = Timer: For n = 1 To x: ID = DLookup("FIELD1", "query36"): Next n
'ts = Timer: For n = 1 To x: ID = CurrentDb.OpenRecordset("q uery36")!F IELD1: Next n
Debug.Print Timer - ts
End Function
DLookup: 71.59399
Open Recordset: 64.45398
mx
Dim x As Long, n As Long, ID
Dim ts
x = 50000
ts = Timer: For n = 1 To x: ID = DLookup("FIELD1", "query36"): Next n
'ts = Timer: For n = 1 To x: ID = CurrentDb.OpenRecordset("q
Debug.Print Timer - ts
End Function
DLookup: 71.59399
Open Recordset: 64.45398
mx
parmarparveen: What didn't you like about the answer such that you rewarded a B with absolutely no feedback? A share would have been in order as both mx and mathewspatrick provided two ways of getting the variable, and I provided a variation on the theme, along with some test methodology and test results. Mx went the extra mile and gave you his test methodology and results. I am requesting you ask Community Support to re-open the question so it may be closed properly. You should never close a question in that manner without giving the participants to correct any shortcoming you have observed.
oops ... parmarparveen ... gRay meant that you should split the points between the 3 of us, and really gRay had the most efficient solution. Can you once again Request Attention and fix this?
thx.mx
thx.mx
ASKER
Thanks
thank you.
mx
mx
SomeString = CurrentDb.OpenRecordSet("q
and is it as faster or slower than the DLookup()