Re: Closing a Form after Validation
Thank you DBguy! That works great.
Of course that leads to the next step that I'm trying to figure out and that is checking to see if the all the controls are empty and if so, clicking the Close button allows the form to close.
I could present a separate thread but I think it might be fine here.
Here's what I've tried in the form F_Project, CloseButton On Click event.
#Private Sub Command5CloseButton_Click()
'This is for the close button.
If CheckForEmpty(Me) = False Then
ElseIf ValidationOfControl(Me) = False Then
And the public function CheckForEmpty,
#Public Function CheckForEmpty(frm As Access.Form) As Boolean
Dim ctl As Control
Dim boolEmptyBox As Boolean
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
If (IsNull(ctl.Value) Or ctl.Value = "") Then
boolEmptyBox = True
CheckForEmpty = boolEmptyBox
I can't figure out why it doesn't work.