Referencing table objects

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?
 
S

Stefan Hoffmann

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 <--
 
D

Douglas J. Steele

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top