Contents of a Field containing a variable name

G

Guest

I need to search throug a Table (both fields and records) that contains a variable name. The Field or Record to go to is unknown. It is calculated. So it comes up with I need the contents of record QXZ172426, Field rst!WN09. How do I get the contents of rst!WN09? I can make it work in ASP and VB6, but not VBA

Example I have a Field in a Table names rst.WN0

Dim db As Databas
Dim rst As Recordse
Dim ChkByte As Byt
Dim wrkIndx As Byt
Dim HoldIt As Strin
Dim WNWN As Byt

Set db = CurrentD

Set rst = db.OpenRecordset("SELECT * FROM UNIVREC"

Do Until rst.EO
wrkIndx =
For wrkIndx = 1 To 2
If wrkIndx < 10 The
HoldIt = "WN0" & wrkInd
Els
HoldIt = "WN" & wrkInd
End I
WNWN = (rst!(= HoldIt)) ' This is where my problem is . WNWN should be 0 or a number from 1 to 129.
MsgBox WNW
Nex
Loo

Been trying for several weeks now. Can this be done

Thanx in Ad

Le
 
K

Ken Snell

Try this:

Do Until rst.EOF
For wrkIndx = 1 To 25
HoldIt = "WN" & Format(wrkIndx, "00")
WNWN = rst!Fields(HoldIt).
MsgBox WNWN
Next


--
Ken Snell
<MS ACCESS MVP>

Len said:
I need to search throug a Table (both fields and records) that contains a
variable name. The Field or Record to go to is unknown. It is calculated.
So it comes up with I need the contents of record QXZ172426, Field
rst!WN09. How do I get the contents of rst!WN09? I can make it work in ASP
and VB6, but not VBA.
Example I have a Field in a Table names rst.WN09

Dim db As Database
Dim rst As Recordset
Dim ChkByte As Byte
Dim wrkIndx As Byte
Dim HoldIt As String
Dim WNWN As Byte

Set db = CurrentDb

Set rst = db.OpenRecordset("SELECT * FROM UNIVREC")

Do Until rst.EOF
wrkIndx = 1
For wrkIndx = 1 To 25
If wrkIndx < 10 Then
HoldIt = "WN0" & wrkIndx
Else
HoldIt = "WN" & wrkIndx
End If
WNWN = (rst!(= HoldIt)) ' This is where my problem
is . WNWN should be 0 or a number from 1 to 129.
 
M

Marshall Barton

Len said:
I need to search throug a Table (both fields and records) that contains a variable name. The Field or Record to go to is unknown. It is calculated. So it comes up with I need the contents of record QXZ172426, Field rst!WN09. How do I get the contents of rst!WN09? I can make it work in ASP and VB6, but not VBA.

Example I have a Field in a Table names rst.WN09

Dim db As Database
Dim rst As Recordset
Dim ChkByte As Byte
Dim wrkIndx As Byte
Dim HoldIt As String
Dim WNWN As Byte

Set db = CurrentDb

Set rst = db.OpenRecordset("SELECT * FROM UNIVREC")

Do Until rst.EOF
wrkIndx = 1
For wrkIndx = 1 To 25
If wrkIndx < 10 Then
HoldIt = "WN0" & wrkIndx
Else
HoldIt = "WN" & wrkIndx
End If
WNWN = (rst!(= HoldIt)) ' This is where my problem is . WNWN should be 0 or a number from 1 to 129.
MsgBox WNWN
Next
Loop


John Vinson provided you with an excellent answer yesterday.

If you have further questions on this issue, please post
them to the original thread so you and everyone else can
keep track of the issues.
 

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