Clear a field in a record with VBA ADO code

N

Nathan Guill

How do I clear a field in a record when using VBA ADO? I thought I would
send "" or EMPTY or NOTHING as the value, but this returns an error.
 
M

Michel Walsh

Hi,


Use Null.

rst.Fields("FieldName") = Null


That assumes the field CAN accept null (some fields, like the primary
key, cannot).

Nothing is to be use for objects only, not for values.

A string with no character, "", is still a string, like zero is still a
number.

NULL is a kind of metadata telling that there is no data available.

Empty, as IsEmpty, is use to see if a variable has been already assigned
(it is quite rare you fall on such beast).

Missing, as IsMissing, is use to see if an optional argument, without
default value, has been supplied.

So, only Null, can do the job, here, to specify that the value of the
field is to be considered absent.



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top