ok - trying to use eval() to abstract out an update operation i need to
perform. I wanted to use the eval() function to avoid HARD CODING
the field names that need to be updated in the target table. As long as the
SQL fields names matched the field names in the target table I expected this
to work. But the eval() function generates an error - it does not
recognize 'asr' as a recordset.
maybe there's in error in my syntax? maybe this is hopeless........and
maybe there is an easier way -- without having to hardcode the target
table's field names..........???
all (any) replies much appreciated. ))
'=========================
SUB mysub(ars as dao.recordset)
'=========================
Dim strSQL As String
Dim rs As dao.Recordset
Dim fld As dao.Field
Dim str As String
On Error GoTo errhdl
strSQL = "SELECT DISTINCT fld1, fld2, fld3, fld4 FROM mytbl WHERE x = y;"
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.EOF And rs.BOF Then
Err.Raise gclngBlankCustomerData
End If
'loop thru all fields in this rs - they should have the same name as the
target tbl fields (on purpose)
'update each match between ars and rs
For Each fld In rs.Fields
If Not IsNull(fld.Value) Then
str = "ars![" & fld.Name & "] = " & Chr(34) & fld.Value & Chr(34)
Eval (str) <==== error is here !
End If
Next
--
kent eilers
ke**@kaeServices.com