No Value in a text string

D

DavidW

How do you refer to a value for a textbox that is linked to a table field
set to text
I am trying to run a mathematical equation to check for duplicated entries,
when the code runs and there is an entry it's fine, but when there is no
match (textbox being empty) it says that the expression I entered has no
value.
How do you refer to a textbox that is text and not numerical since the
isnull statement doesnt function on text?
 
R

Rick Brandt

DavidW said:
How do you refer to a value for a textbox that is linked to a table field
set to text
I am trying to run a mathematical equation to check for duplicated entries,
when the code runs and there is an entry it's fine, but when there is no
match (textbox being empty) it says that the expression I entered has no
value.
How do you refer to a textbox that is text and not numerical since the
isnull statement doesnt function on text?

Your last statement is incorrect. IsNull() does not discriminate on the
DataType of the control or field fed into it.
 
D

DavidW

Your last statement is incorrect. IsNull() does not discriminate on the
DataType of the control or field fed into it.

why does the isnull() statement not catch the empty textbox, or is my
terminolgy wrong?
I know that it looks at the texbox and it steps through the code as if there
was text in the texbox. How do you catch an empty textbox.
 
R

Rick Brandt

DavidW said:
why does the isnull() statement not catch the empty textbox, or is my
terminolgy wrong?
I know that it looks at the texbox and it steps through the code as if there
was text in the texbox. How do you catch an empty textbox.

The TextBox may contain an empty string which is not the same as Null. I
use the following which catches both.

If Len(Nz([SomeControl],""))=0 Then
'the control is either a zero-length-string or Null
End If
 
D

DavidW

Rick I tried the following and still got the same error
"you have entered an expression that has no value"

If Len(Nz([Forms]![onroaduse].Text33, "")) = 0 Then
Exit Sub
End If
Any Ideals as to what I did wrong?
 
T

TC

Rick Brandt said:
Your last statement is incorrect. IsNull() does not discriminate on the
DataType of the control or field fed into it.


He thinks that IsNull() should return True for an empty string. The fact
that it doesn't, leads him to conclude that Isnull() "does not work" with
text.

TC
 
R

Rick Brandt

DavidW said:
Rick I tried the following and still got the same error
"you have entered an expression that has no value"

If Len(Nz([Forms]![onroaduse].Text33, "")) = 0 Then
Exit Sub
End If
Any Ideals as to what I did wrong?

Where are you running this code?

Is the form onroaduse open when the code runs?
 

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