Invalid use of null


L

LAS

I'm trying to solve the problem that the colum ProbBehaveCat2_desc is not
getting updated, even though the code below is getting executed. A mystery
or a clue is that when the gs_debug... statement is executed, I get an
error, "Invalid use of null." Why do I get the error there and not in the
statement preceding? gs_debug is a public global string. The combo box
looks good, and puts the chosen item in the field.

irst_StudentTracking!ProbBehaveCat2_Desc = cboProbBehave2.Column(2)
gs_Debug = cboProbBehave2.Column(2) 'This is the row that causes
the error
irst_StudentTracking.Update
 
Ad

Advertisements

S

Stuart McCall

LAS said:
I'm trying to solve the problem that the colum ProbBehaveCat2_desc is not
getting updated, even though the code below is getting executed. A
mystery or a clue is that when the gs_debug... statement is executed, I
get an error, "Invalid use of null." Why do I get the error there and not
in the statement preceding? gs_debug is a public global string. The
combo box looks good, and puts the chosen item in the field.

irst_StudentTracking!ProbBehaveCat2_Desc = cboProbBehave2.Column(2)
gs_Debug = cboProbBehave2.Column(2) 'This is the row that causes
the error
irst_StudentTracking.Update

The reason you're not getting the error on the preceding statement is that
you're assigning the columnar value to a recordset field, which can accept
nulls. On the line that errors you're assigning to a string variable, which
can't handle nulls.

However it's easily fixed. Use The Nz (Null to Zero) function, thus:

gs_Debug = Nz(cboProbBehave2.Column(2))
 
Ad

Advertisements

D

David W. Fenton

I'm trying to solve the problem that the colum ProbBehaveCat2_desc
is not getting updated, even though the code below is getting
executed. A mystery or a clue is that when the gs_debug...
statement is executed, I get an error, "Invalid use of null." Why
do I get the error there and not in the statement preceding?
gs_debug is a public global string. The combo box looks good, and
puts the chosen item in the field.

irst_StudentTracking!ProbBehaveCat2_Desc =
cboProbBehave2.Column(2) gs_Debug =
cboProbBehave2.Column(2) 'This is the row that causes
the error
irst_StudentTracking.Update

Stop editing a copy of the form's recordset. Edit THE FORM ITSELF.

You're really making things much more difficult for yourself than
you need to.

Are you a refugee from a programming environment in which there are
not bound forms/controls? If so, you need to back up and start
learning Access like you are a novice and end user and know nothing
at all about high-level programming.

99% of your editing in Access should involve no code at all.
 

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