12 Items to check for Null

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

Guest

I have a form with 4 lines of info containing 12 textboxex/comboboxes. Each
line starts with a Y/N check box.

I would like to check each textbox/combobox for data, and if it exists,
prompt the user to confirm they wish to remove the data from that line.

Currently I am using:

If Not IsNull([Unit1Region]) Then
If MsgBox("my message", vbYesNo) = vbYes Then
Me.Unit1region = Null


I want to avoid using If Not IsNull for all 12 ( X 4 lines)
textboxes/comboboxes, but I don't know of a more efficient method.

Any advice is always appreciated.

Cheers
 
Paul said:
I have a form with 4 lines of info containing 12 textboxex/comboboxes. Each
line starts with a Y/N check box.

I would like to check each textbox/combobox for data, and if it exists,
prompt the user to confirm they wish to remove the data from that line.

Currently I am using:

If Not IsNull([Unit1Region]) Then
If MsgBox("my message", vbYesNo) = vbYes Then
Me.Unit1region = Null


I want to avoid using If Not IsNull for all 12 ( X 4 lines)
textboxes/comboboxes, but I don't know of a more efficient method.


You can loop through all the controls on the form or in a
section.

You will need some way to identify which ones to confirm.
If it's every text box, you can just check the type of the
control, but to be more discriminating set each text box's
Tag property to something indicitive such as CONFIRM.

Dim ctl As Control
For Each ctl In Me.Section(0).Controls 'detail section
If ctl.Tag = "CONFIRM" Then
If Not IsNull(ctl) Then
If MsgBox("... " & ctl.Name, vbYesNo) = vbYes Then
ctl = Null
End If
End If
End If
Next ctl
 
Thanks Marsh,

I will use your TAG suggestion as I should have said the form has other
textboxes/comboboxes that I don't need to check for Null.

Cheers


Marshall Barton said:
Paul said:
I have a form with 4 lines of info containing 12 textboxex/comboboxes. Each
line starts with a Y/N check box.

I would like to check each textbox/combobox for data, and if it exists,
prompt the user to confirm they wish to remove the data from that line.

Currently I am using:

If Not IsNull([Unit1Region]) Then
If MsgBox("my message", vbYesNo) = vbYes Then
Me.Unit1region = Null


I want to avoid using If Not IsNull for all 12 ( X 4 lines)
textboxes/comboboxes, but I don't know of a more efficient method.


You can loop through all the controls on the form or in a
section.

You will need some way to identify which ones to confirm.
If it's every text box, you can just check the type of the
control, but to be more discriminating set each text box's
Tag property to something indicitive such as CONFIRM.

Dim ctl As Control
For Each ctl In Me.Section(0).Controls 'detail section
If ctl.Tag = "CONFIRM" Then
If Not IsNull(ctl) Then
If MsgBox("... " & ctl.Name, vbYesNo) = vbYes Then
ctl = Null
End If
End If
End If
Next ctl
 
Back
Top