Tom said:
Thanks, That helped.
A further question:
If i want to check whether this 'cell' is empty, how would i do this,
because
if rs1.Fields(Variable1) = "" then...
does not do it.
The zero-length string, "", is itself a value, and not the same as empty or
Null. Usually you want to check a field to see if it is Null, which you can
do in VBA like this:
If IsNull(rs1.Fields(Variable1)) Then.
Text and memo fields can hold zero-length strings, and sometimes you may
want to check if such a field is either Null or a ZLS. In that case, you
can use a short-cut to check for both possibilities at once, like this:
If Len(rs1.Fields(Variable1) & "") = 0 Then
The concatenation forces the value, if Null, to a zero-length string. Note
that you have no reason to do this with other types of fields, as they can't
hold string values.
And how do i edit this field.+
That depends on what kind of recordset you have. If it's a DAO recordset,
then you have to put the recordset first into Edit mode, then modify the
values, and then Update the record:
With rs1
.Edit
.Fields(Variable1) = "foo" ' a text field
.Fields(Variable2) = 123 ' a number field
.Update
End With
If it's an ADO recordset, you don't have to call any .Edit method, but you
still have to call the .Update method to save the changed record.