Hi all,
i have a command button that appends a record on a form when pressed. I have a condition before it which prompts a user if compulsory fields are not filled in, to fill them in or append is not carried out. The problem with my code is i cannot seem to display all the text and comboboxes that have not been filled in, on one messagebox. The code i have displays them in seperate message boxes.
e.g. if 3 compulsory text or comboboxes are null:
"The following text or comboboxes have to be filled in:
textbox1
textbox2
combobox3
if 2 then:
textbox1
textbox2
I want to display on a message box all compulsory boxes that have not yet been filled in. This is my code so far:
The above code displays text or comboboxes that i have placed Required under in their tag property. I want to display all the control names that have required on their tag property and are not filled in (i.e. null) on one messagebox.
Any help appreciated, thanks in advance,
M-.
i have a command button that appends a record on a form when pressed. I have a condition before it which prompts a user if compulsory fields are not filled in, to fill them in or append is not carried out. The problem with my code is i cannot seem to display all the text and comboboxes that have not been filled in, on one messagebox. The code i have displays them in seperate message boxes.
e.g. if 3 compulsory text or comboboxes are null:
"The following text or comboboxes have to be filled in:
textbox1
textbox2
combobox3
if 2 then:
textbox1
textbox2
I want to display on a message box all compulsory boxes that have not yet been filled in. This is my code so far:
Code:
dim ctl AS control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
If Me(ctl.NAME) = "" Or IsNull(Me(ctl.NAME)) Then
If ctl.Tag = "Required" Then
MsgBox "You have a Text box with no value, " & _
"The Text Box name is:" & vbCrLf & ctl.NAME, _
vbExclamation, Me.Caption
ctl.SetFocus
Me.ActiveControl.BackColor = vbYellow
Exit Sub
End If
End If
End If
Next
The above code displays text or comboboxes that i have placed Required under in their tag property. I want to display all the control names that have required on their tag property and are not filled in (i.e. null) on one messagebox.
Any help appreciated, thanks in advance,
M-.