Referencing table objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can reference a field in a table using a variable. Say you have 3 fields
in a table named rstable. In the example below I want reference the three
fields by replacing Field1, Field2, Field3 with Fieldx.

For x = 1 to 3
Select Case rstable!Field1
case "PASS"
Beep
Select End
next x

Can this be done?
 
hi a,
How can reference a field in a table using a variable. Say you have 3 fields
in a table named rstable. In the example below I want reference the three
fields by replacing Field1, Field2, Field3 with Fieldx.

For x = 1 to 3
Select Case rstable!Field1
case "PASS"
Beep
Select End
next x
Use rstable("Field" & CStr(x)).

mfG
--> stefan <--
 
Well, you can't reference fields in tables, but assuming you actually mean a
recordset, it would be:

For x = 1 to 3
Select Case rstable.Fields("Field" & x)
case "PASS"
Beep
Select End
next x

On the other hand, having a requirement like that makes me suspect that your
table isn't properly normalized: that Field1, Field2 and Field3 are a
repeating group.
 
Back
Top