null error

  • Thread starter Thread starter mark kubicki
  • Start date Start date
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
 
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")
 

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

Back
Top