I'm sure this question has probably been asked before, but I don't have time to hunt for the answer.
Here is an simplified example of my problem:
dim fieldname as string
dim rec as recordset
dim ordernumber as integer
fieldname = "OrderId"
set rec = currentdb.openrecordset("tblorders"
rec.movefirst
ordernumber = rec![fieldname]
What I want it to do is look up the information based on whatever I specify for the variable 'fieldname', i.e. if I set 'fieldname = cost', then it would return rec!cost, if I set 'fieldname = orderid, then it would return rec!orderid, etc. I have also tried declaring fieldname as a variant. I have struggled with this problem for several hours and have become quite frustrated. Any help you can give me would be greatly appreciated!!
Thanks
[sig]<p>Mike Rohde<br><a href=mailto:rohdem@marshallengines.com>rohdem@marshallengines.com</a><br>[/sig]
Here is an simplified example of my problem:
dim fieldname as string
dim rec as recordset
dim ordernumber as integer
fieldname = "OrderId"
set rec = currentdb.openrecordset("tblorders"
rec.movefirst
ordernumber = rec![fieldname]
What I want it to do is look up the information based on whatever I specify for the variable 'fieldname', i.e. if I set 'fieldname = cost', then it would return rec!cost, if I set 'fieldname = orderid, then it would return rec!orderid, etc. I have also tried declaring fieldname as a variant. I have struggled with this problem for several hours and have become quite frustrated. Any help you can give me would be greatly appreciated!!
Thanks
[sig]<p>Mike Rohde<br><a href=mailto:rohdem@marshallengines.com>rohdem@marshallengines.com</a><br>[/sig]