Check all unbound text boxes for Null

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

Guest

I have a form which is unbound. The user selects a save button to write the
values to a record in a table which I handle in code with rst.addnew etc. I
want to check that all controls have data before the code is run. Tried the
following but it seems to ignore it?

Dim NullFlag As Boolean

NullFlag = False

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Value = Null Then
NullFlag = True
End If
End If
Next ctl

If NullFlag = True Then
Msg = "You must enter a value in ALL fields to be able to Post a
Transaction"
MsgBox Msg, vbCritical, "Data Entry Incomplete"

Can anyone help with this please?

Sue
 
Thanks - copied someone else's example off newsgroups. Don't know why I
didn't try that though! DOH...

Sue
 
Back
Top