Invalid use of NULL

battenberg

Burning candles both ends
Local time
Today, 08:34
Joined
Sep 25, 2006
Messages
118
Any tips on the following?

against every customer in my DB I have a notes field in the table.

I want to be able to update the [notes] field with a string concatenation based on multiple entries from a form.

my code (simplyfied) is along these lines.

Code:
dim strNotes as String
dim strConcatenation as string 

' dim a whole bunch of strings 
' this bit collects a whole bunch of strings 
'that will become the string concatenation (not shown)

Notes.setfocus
strNotes = [Notes]
strNotes = strNotes & " " & strConcatenation
[Notes] = strNotes
however I get the error 'Invalid use of NULL' if the original [notes] is empty to start with.

I have tried to write an if routene for (if strNotes = "") etc... but had no luck

can anyone point me towards the correct way of handling NULL given this scenario.
 
Last edited:
You can just say:

[Notes] = [Notes] & " " & strConcatenation

There is no need to assign the value of [Notes] to a variable first.

Of course, if [Notes] is null, there will be an extra leading space. You could use:

[Notes] = ([Notes] + " ") & strConcatenation

if you do not want the extra leading space.
 
Something like:

me!myNoteFieldName = me!myNoteFieldName & strNotes

???
 
Thank you both for your quick and simple replies...

After playing about mostly with VB6 and excel VBA - moving to Access I find it has has a slightly different angle on the way things are done..!

but learning day by day!!!

Thanks again...very Much appreciated!!!
 
And as a third way, you could modify one line of your original code to:

Code:
strNotes = Nz([Notes],"")
 

Users who are viewing this thread

Back
Top Bottom