Recordset variable?

jjyxk845

Board Regular
Joined
Sep 8, 2006
Messages
89
Hi I hope this will have a simple answer.

I have the following code.


Code:
output = rs!age33


but what i want is to use a variable instead of age33


this is what i hoped would work but didn't and should help explain things
clearer.


Code:
lookup_age = 33 

Query_Age = "Age" & Lookup_Age 

output = rs!query_age

this way i can select any "age" can anyone help
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I think we would need to know more about how you have created the recordset but perhaps something like this might work?
Code:
rs.Fields("age33")
Where you could replace the "age33" with a variable.
 
Upvote 0
That worked great Thank you very much.

this was how i defined the recordset

Code:
Query = "SELECT * FROM list WHERE Name='" & Lookup_list & "'"
rs.Open Query, Cnn, adOpenForwardOnly, adLockReadOnly, adCmdText
 
Upvote 0

Forum statistics

Threads
1,207,110
Messages
6,076,604
Members
446,216
Latest member
BEEALTAIR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top