null error

M

mark kubicki

behind a command button on a form I have the code:
the fields: LampCnt1 and LampCnt2 are both numeric fields and may or may not
have had values entered

BuildText = ""
.. . .
BuildText = BuildText & (" " + CStr(frm.LampCnt1 + frm.LampCnt2) + "-lamp")
.. . .

this line of code is generating an invalid use of null (?) error


any suggestions why?.
thanks in advance,
mark
 
M

Marshall Barton

mark said:
behind a command button on a form I have the code:
the fields: LampCnt1 and LampCnt2 are both numeric fields and may or may not
have had values entered

BuildText = ""
. . .
BuildText = BuildText & (" " + CStr(frm.LampCnt1 + frm.LampCnt2) + "-lamp")
. . .

this line of code is generating an invalid use of null (?) error


CStr does not allow Null values. Not only that, but when
you use + to concatenate (string/text) values, any Null will
make the result Null.

Use:

.. . . & (" " & (frm.LampCnt1 & frm.LampCnt2) & "-lamp")

or, if you really fo want to add the numbers in the lamp
textboxes:

.. . . & (" " & (Nz(frm.LampCnt1,0) + Nz(frm.LampCnt2,0) &
"-lamp")
 
Top