Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Question: A cell on a form has no data 1

Status
Not open for further replies.

Ogart

Technical User
Mar 26, 2003
104
US
Greetings:

I can't quite get this syntax right.
A is a form that I'm entering data in. The field "PipeSize" won't have data in it until the user puts in data (from a pull down if that matters). If the cell is empty, that's a problem for the calculation downstream, so what I need to do first is see if that cell is empty. If it is, I'll skip the calculation, basically.

I thought I got this to work, but what's turning out to be the problem is my code isn't skipping the calculation the way it should becuase it isn't recognizing the cell of data is empty, the way it should. Wierd.

Here's the piece of code I wrote to figure out what syntax will work. When the cell has a value in it, life is good. When the cell is emtpy, (it's text), I get the final debug message ("apparently none of these apply").

Oh, one more thing, the first thing I get is "Null" This is from the first line of code below.

Debug.Print A!PipeSize
If A!PipeSize = Null Then
Debug.Print "Pipe size is null"
ElseIf A!PipeSize = "" Then
Debug.Print "Pipe size is double quote"
ElseIf A!PipeSize = 0 Then
Debug.Print "PipeSize is zero"
Else
Debug.Print "apparently, none are the case"
End If

After some cursing, more than a little RTFMing, and finally a shrugged shoulder, I bow to the collective greatness that is "outside help".

Regards,
Chris


-->Just because you can, doesn't mean you should.
 
hey Chris.

try this:

If IsNull(me.PipeSize) Then
Debug.Print "Pipe size is null"
ElseIf me.PipeSize = "" Then
Debug.Print "Pipe size is double quote"
ElseIf me.PipeSize = 0 Then
Debug.Print "PipeSize is zero"
Else
Debug.Print "apparently, none are the case"
End If


 
Use Nz(A!PipeSize) in stead.
The Nz function is doing what you need:

If IsNull(A!PipeSize) then
A!PipeSize=0
End If

Write the Nz(A!PipeSize) in your module, place the cursor on the Nz and press F1, this will supply all the Help that you might need.

Good luck.
Hans
 
I ended up using this:
If Len(Nz(A!Pipesize,""""))=0 Then
blah blah blah
End if

Great vector. Thank you.


-->Just because you can, doesn't mean you should.
 
if nz(A!Pipesize)=0 then
blabla
end if

would also do the job.
I suppose A!Pipesize is a numeric field.
Hans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top