Changing null to "" in a form field.

  • Thread starter Thread starter LAS
  • Start date Start date
L

LAS

What is the recommended way to make sure that when the contents of an
unbound field are deleted, the contents will contain an empty string instead
of null?

TIA
LAS
 
You could use the AfterUpdate event of the control:

Private Sub NameOfControl_AfterUpdate()
If Len(Me.NameOfControl.Value & "") = 0 Then Me.NameOfControl.Value = ""
End Sub

or

Private Sub NameOfControl_AfterUpdate()
Me.NameOfControl.Value = Nz(Me.NameOfControl.Value, "")
End Sub
 
Thanks much!

Ken Snell said:
You could use the AfterUpdate event of the control:

Private Sub NameOfControl_AfterUpdate()
If Len(Me.NameOfControl.Value & "") = 0 Then Me.NameOfControl.Value = ""
End Sub

or

Private Sub NameOfControl_AfterUpdate()
Me.NameOfControl.Value = Nz(Me.NameOfControl.Value, "")
End Sub
 
You could use the AfterUpdate event of the control:

Private Sub NameOfControl_AfterUpdate()
If Len(Me.NameOfControl.Value & "") = 0 Then
Me.NameOfControl.Value = "" End Sub

I don't understand this, since it's going to set the value to a ZLS
when it's already a ZLS. You only need to do it when it's Null:

If IsNull(Me!NameOfControl) Then
Me!NameOfControl = vbNullString
End If
 
Back
Top