Finding Empty Fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am trying to update a field only if it has no information in it already,
here is what I have...

Private Sub TxtSublot_GotFocus()
If [TxtSublot] = Null Then
[TxtSublot] = [txtLotNumber] + "-"
End If
End Sub

This does not seem to be working. I also tried...

If [TxtSublot] = ""

Any ideas on where I'm going wrong?
 
hi
try this
Private Sub TxtSublot_GotFocus()
If IsNull Me.[TxtSublot] Then
Me.[TxtSublot] = Me.[txtLotNumber] + "-"
End If
End Sub
 
That worked, thanks Rick!

Rick B said:
IsNull([TxtSublot])


Zaz said:
Hello,

I am trying to update a field only if it has no information in it already,
here is what I have...

Private Sub TxtSublot_GotFocus()
If [TxtSublot] = Null Then
[TxtSublot] = [txtLotNumber] + "-"
End If
End Sub

This does not seem to be working. I also tried...

If [TxtSublot] = ""

Any ideas on where I'm going wrong?
 
Be careful with this though, because the field may be empty (blank) and not
null. For example, if a user types something into a field but then deletes
the contents, the field is no longer null -- it's blank/empty (i.e.,
contains a zero-length string).

I always code my tests for this type of condition as follows:

if trim(nz(me.field,"")) = "" then ...

The nz function replaces a null field with an empty (zero length string).
The trim eliminates any blanks that might be sitting in the field (someone
could have typed in blanks). As a result, if the field is null, has a zero
length string in it, or has just blanks in, it's going to evaluate as being
"empty"

Zaz said:
That worked, thanks Rick!

Rick B said:
IsNull([TxtSublot])


Zaz said:
Hello,

I am trying to update a field only if it has no information in it already,
here is what I have...

Private Sub TxtSublot_GotFocus()
If [TxtSublot] = Null Then
[TxtSublot] = [txtLotNumber] + "-"
End If
End Sub

This does not seem to be working. I also tried...

If [TxtSublot] = ""

Any ideas on where I'm going wrong?
 
Back
Top