with statement (1 Viewer)

n7kon

New member
Local time
Yesterday, 19:27
Joined
Apr 29, 2012
Messages
7
In a with statement can you refer to a field header using a variable?
With rsNoun
.MoveFirst
Do Until .EOF
If !jde = strAJDE Then
.Edit
!strName = strinfo (here is where I am trying it. )
.Update
End If
.MoveNext
Loop
End With
The strHead is passed to this function from another. The strName is a match for a column name in the table rsNoun. After it updates the field that has the same name as strName with strInfo it will go back to the other function and get a new strName and strinfo bring down.
Thanks for any ideas Keith
 
Local time
Today, 12:27
Joined
Aug 8, 2010
Messages
245
My guess is that you need to open 2 different recordsets. (Can't see the rest of your code for this).
One recordset will get the value for strinfo for one row of the table rsNoun.

The next recordset will take strinfo and put it into the field called strName as in your sample code.

After you add the value for strinfo, do a move next on the first recordset and get the next value for strName then use it in the second recordset.
 

n7kon

New member
Local time
Yesterday, 19:27
Joined
Apr 29, 2012
Messages
7
Thanks Wayne worked like a champ. I was stuck looking for something harder and could not see what should have been right in front of me. Thanks again for the help.

Jeanette the strinfo was passed to the function so was good there but thanks for the try.

Keith
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 12:27
Joined
Jan 20, 2009
Messages
12,854
BTW. Members of the Fields Collection can also be referred to by their index number. It can be quite useful in loops. The first field has the index zero.

.Fields(n)
 

Users who are viewing this thread

Top Bottom