Invalid use of Null

J

Jacco

Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and atleast
ONE of them needs to contain value. I've tried several approaches, but just
can't get it to work. Untill somebody enters a value in the fields, the are
set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value + [IP].Value
If CommandTime = 0 Then GoTo Forgot_new1_Click


Thank you in advance
Jacco
 
L

Lynn Trapp

You need to wrap them in the Nz() Function.

CommandTime = Nz([PIC].Value,0) + Nz([SIC].Value,0) .....

Do that to all your fields.
 
R

Rick Brandt

Jacco said:
Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and
atleast ONE of them needs to contain value. I've tried several
approaches, but just can't get it to work. Untill somebody enters a
value in the fields, the are set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value +
[IP].Value If CommandTime = 0 Then GoTo Forgot_new1_Click

CommandTime = Nz([PIC], 0) + Nz([SIC], 0) + Nz([Dual], 0) + Nz([IP], 0)
If CommandTime = 0 Then (anything but GoTo :))
 
J

Jacco

This works for is the actual values are empty. Then, when it validates and
one of the Values is set to 1:00 it freezes saying:

Run-time error '13'

Type mismatch


Lynn Trapp said:
You need to wrap them in the Nz() Function.

CommandTime = Nz([PIC].Value,0) + Nz([SIC].Value,0) .....

Do that to all your fields.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Jacco said:
Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and
atleast
ONE of them needs to contain value. I've tried several approaches, but
just
can't get it to work. Untill somebody enters a value in the fields, the
are
set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value + [IP].Value
If CommandTime = 0 Then GoTo Forgot_new1_Click


Thank you in advance
Jacco
 
L

Lynn Trapp

What kind of information are you storing in those fields?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Jacco said:
This works for is the actual values are empty. Then, when it validates and
one of the Values is set to 1:00 it freezes saying:

Run-time error '13'

Type mismatch


Lynn Trapp said:
You need to wrap them in the Nz() Function.

CommandTime = Nz([PIC].Value,0) + Nz([SIC].Value,0) .....

Do that to all your fields.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Jacco said:
Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and
atleast
ONE of them needs to contain value. I've tried several approaches, but
just
can't get it to work. Untill somebody enters a value in the fields, the
are
set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value + [IP].Value
If CommandTime = 0 Then GoTo Forgot_new1_Click


Thank you in advance
Jacco
 
J

Jacco

Time Values (1:00:00) etc. It's a logbook interface (pilot)
I want to make sure one of the fields has a value. If so, then nothing needs
to be done (better said, they can post the info into the table) and if none
exsist (all are Null), a msbx pops up saying they have to check the form and
correct the entries. So far I get either one working, just never at the same
time.

Lynn Trapp said:
What kind of information are you storing in those fields?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Jacco said:
This works for is the actual values are empty. Then, when it validates
and one of the Values is set to 1:00 it freezes saying:

Run-time error '13'

Type mismatch


Lynn Trapp said:
You need to wrap them in the Nz() Function.

CommandTime = Nz([PIC].Value,0) + Nz([SIC].Value,0) .....

Do that to all your fields.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


"Jacco" <jacco[at]vliegt.nl> wrote in message
Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and
atleast
ONE of them needs to contain value. I've tried several approaches, but
just
can't get it to work. Untill somebody enters a value in the fields, the
are
set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value + [IP].Value
If CommandTime = 0 Then GoTo Forgot_new1_Click


Thank you in advance
Jacco
 
R

Rick Brandt

Jacco said:
This works for is the actual values are empty. Then, when it
validates and one of the Values is set to 1:00 it freezes saying:

Run-time error '13'

Type mismatch

Try...

Nz(ControlName, 0.00)

....instead of...

Nz(ControlName, 0)

The latter might be forcing integer math and for time you need the result as
a Double.
 
S

schasteen

Try the isnull function

IF isnull([PIC]) AND isnull([SIC]) AND isnull([Dual]) AND isnull([IP]) then
msgbox("Correct entries")
else
???
end if

Jacco said:
Time Values (1:00:00) etc. It's a logbook interface (pilot)
I want to make sure one of the fields has a value. If so, then nothing needs
to be done (better said, they can post the info into the table) and if none
exsist (all are Null), a msbx pops up saying they have to check the form and
correct the entries. So far I get either one working, just never at the same
time.

Lynn Trapp said:
What kind of information are you storing in those fields?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Jacco said:
This works for is the actual values are empty. Then, when it validates
and one of the Values is set to 1:00 it freezes saying:

Run-time error '13'

Type mismatch


You need to wrap them in the Nz() Function.

CommandTime = Nz([PIC].Value,0) + Nz([SIC].Value,0) .....

Do that to all your fields.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


"Jacco" <jacco[at]vliegt.nl> wrote in message
Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and
atleast
ONE of them needs to contain value. I've tried several approaches, but
just
can't get it to work. Untill somebody enters a value in the fields, the
are
set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value + [IP].Value
If CommandTime = 0 Then GoTo Forgot_new1_Click


Thank you in advance
Jacco
 
J

Jacco

Solution found:

If CommandTime = "0"... (I forgot a set of quotes...)

Jacco

Jacco said:
Time Values (1:00:00) etc. It's a logbook interface (pilot)
I want to make sure one of the fields has a value. If so, then nothing
needs to be done (better said, they can post the info into the table) and
if none exsist (all are Null), a msbx pops up saying they have to check
the form and correct the entries. So far I get either one working, just
never at the same time.

Lynn Trapp said:
What kind of information are you storing in those fields?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


Jacco said:
This works for is the actual values are empty. Then, when it validates
and one of the Values is set to 1:00 it freezes saying:

Run-time error '13'

Type mismatch


You need to wrap them in the Nz() Function.

CommandTime = Nz([PIC].Value,0) + Nz([SIC].Value,0) .....

Do that to all your fields.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


"Jacco" <jacco[at]vliegt.nl> wrote in message
Hi everyone,

I'm trying to validate a form, using VB. I have 4 time fields, and
atleast
ONE of them needs to contain value. I've tried several approaches, but
just
can't get it to work. Untill somebody enters a value in the fields,
the are
set to Null.

I ended up trying this, but it won't process Null values and crash:

Dim CommandTime As String

CommandTime = [PIC].Value + [SIC].Value + [Dual].Value + [IP].Value
If CommandTime = 0 Then GoTo Forgot_new1_Click


Thank you in advance
Jacco
 
Top