and another (probably) quick one:
This function is supposed to empty a specified field in a table. The function accepts a parameters for the name of the field.... but what is correct eval() usage?
Function emptyfield(tablename As String, fieldname As String) As Boolean
Dim db As Database, rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM [" & tablename & "];", dbOpenDynaset)
If rs.EOF = True And rs.BOF = True Then
emptyfield = False
rs.Close: Set rs = Nothing: db.Close: Set db = Nothing
Exit Function
End If
rs.MoveFirst
Do Until rs.EOF = True
rs.Edit
rs![eval(fieldname)] = "" <<<<<<< !!!!
rs.Update
rs.MoveNext
Loop
rs.Close: Set rs = Nothing: db.Close: Set db = Nothing
End Function
appreciate any ideas...
regards
waldemar
This function is supposed to empty a specified field in a table. The function accepts a parameters for the name of the field.... but what is correct eval() usage?
Function emptyfield(tablename As String, fieldname As String) As Boolean
Dim db As Database, rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM [" & tablename & "];", dbOpenDynaset)
If rs.EOF = True And rs.BOF = True Then
emptyfield = False
rs.Close: Set rs = Nothing: db.Close: Set db = Nothing
Exit Function
End If
rs.MoveFirst
Do Until rs.EOF = True
rs.Edit
rs![eval(fieldname)] = "" <<<<<<< !!!!
rs.Update
rs.MoveNext
Loop
rs.Close: Set rs = Nothing: db.Close: Set db = Nothing
End Function
appreciate any ideas...
regards
waldemar