Problem finding a column in a table using variables

  • Thread starter Thread starter CD Tom
  • Start date Start date
C

CD Tom

Here's what i'm trying to do.
Strsql = "select * from master where membernumber = " & Vmbrnumber & ""
set rs = db.openrecordset(strsql)
i = VNumber ' this is a varaible number depending on the column I want to
look up
VTime = rs("Time" & i) ' this should be column time1 if Vnumber = 1

I get a error Item not found in collection.
Can anybody let me know how to do this.
 
Here's what i'm trying to do.
Strsql = "select * from master where membernumber = " & Vmbrnumber & ""
set rs = db.openrecordset(strsql)
i = VNumber ' this is a varaible number depending on the column I want to
look up
VTime = rs("Time" & i) ' this should be column time1 if Vnumber = 1

I get a error Item not found in collection.
Can anybody let me know how to do this.

Try rs.Fields("Time" & i)

But if you have multiple Time fields your table structure is not properly
normalized! It's a good spreadsheet but if you have a one (member) to many
(times) relationship you would do better to have two tables in a one to many
relationship.
 
Back
Top