I have created an access database which uses forms for user data entry. I have implemented validation coding
on the main form which works fine and highlights empty required fields that user has not filled out. Save is not allowed
until the user finishes filling out all the fields. On this form I have a subform which is linked to the main form by a case number.
I cant get the validation code to do the same thing on the subform. When I open up the subform by itself the code
executes just fine, but when executed from within the subform I am not getting the same result.
Here is the code that I am using which works fine on the main form and on the subform when opened by itself. Any help and
insight would be appreciated. Thank you
Private Sub btnSaveClient_Click()
Dim strMsg As String, strTitle As String
If ValidateFormComplete1 Then
strMsg = "Do You Want To Save This Record?"
strTitle = " Save Record ?"
If MsgBox(strMsg, vbQuestion + vbYesNo, strTitle) = vbNo Then
MsgBox "The case information has been saved. Proceed to enter defendant and plaintiff information below"
MsgBox "The Small Claims Case Worksheet is not complete. Please complete all highlighted fields"
Private Function ValidateFormComplete1() As Boolean
Dim Ctr As Control
Dim FoundError As Boolean
FoundError = False
For Each Ctr In Screen.ActiveForm.Controls
Select Case Ctr.ControlType
Case acComboBox, acTextBox, acCheckBox, acOptionBox
If Ctr.Tag = "*" Then
If IsNull(Ctr.Value) Or Ctr.Value = "" Then
Ctr.BackColor = RGB(223, 167, 165)
FoundError = True
Ctr.BackColor = RGB(255, 255, 255)
ValidateFormComplete = Not FoundError
I believe the issue is most likely the referencing of the subform on the main form to get the code to execute
properly but I cant pinpoint it. Thanks again