Update a field

  • Thread starter Thread starter James Bertino
  • Start date Start date
J

James Bertino

I'm trying to update a table. the table has different field names at
different times. I'm using the DAO method and this code;

++++++++++++
With rs
Do While Not .EOF
.Edit
LowerVal = LBound(varFdNames)
UpperVal = UBound(varFdNames)
For i = LowerVal To UpperVal
Debug.Print mPercent
strFdName = "!" & varFdNames(i) ' Gives the value !Field.Name not
!Field.Value
' Get the original string
strText = !Desc
' Get the updated string
!Desc = cleanUpField(strText)
.Update
.Close
Next
mPercent = mPercent + 1
mMeter = SysCmd(acSysCmdUpdateMeter, mPercent)
Loop
End With
+++++++++++++++++

Howerver the DAO object doesn't seem to like passing a varible for the field
name. What I get is the field name and not the field value for the value of
the variable. Is there a way of making this work or should i recreate the
table and pass the value though my procedure for cleaning, then delete the
original table and rename the output table?
thanks in advance
Jay
 
Thank you Andrew,
That did it. I'll bone up on passing variables. I'll have to because now I'm
finding another unwanted result.

++++++++++
With rs
Do While Not .EOF
.Edit
LowerVal = LBound(varFdNames)
UpperVal = UBound(varFdNames)
For i = LowerVal To UpperVal
' Get the original string
strText = rs(varFdNames(i))
Debug.Print mPercent & " - " & strText
' Get the updated string
rs(varFdNames(i)) = cleanUpField(strText)
Next
'Debug.Print mPercent
mPercent = mPercent + 1
mMeter = SysCmd(acSysCmdUpdateMeter, mPercent)
Loop
..Update
..Close
End With
++++++++++

When the code advances to the next record the strText variable isn't being
updated. What did I forget?
Jay
 
I can't see anything that moves to the next record in your Do loop. You
probably need a .MoveNext before Loop. Also I think you'll need a .Edit and
a .Update for each record, so the .Update will need to be inside the Loop.
 
Thanks again Andrew, I noticed it yesterday like 5 minutes after I
submitted. Sorry about that.
Jay
 
Back
Top