Hi!

I'm trying to write a function with the following purpose:

I'll have a few forms (3-5) and in each of them there'll be some commad buttons to perform some actions. These buttons will become enabled once some controls (textboxes, comboboxes, etc) have certain values in them. What I want is to have a function that returns a true value if all the conditions are met. My idea is a follows:

1) I'll send an array of conditions (string variables) with the following format: "TxtBox_Name_Available = Available, TxtBox_Rate = has numeric value", ComboBox_Month = has a month, ComboBox_Year = has a year". (ControlName = Control.value)
2) The function will then procede to compare each control's value against the expected content that validates the condition as true.
3) If all conditions are true then the function returns true. If only one conditions is not true then the functions returns false and the commad button remains disabled.

I think I can build the function if it's going to be used only for the controls on one form but I'd like it to handle as many forms as I want. I thought that maybe, the form could be sent as a parameter but I really don't know how. So far, the functions looks like this:


Public Function CheckConditions(ParamArray Condiciones() As Variant) As Boolean

    Dim i As Integer
    
    Dim Condición As String
    
    Dim MyControl As Control
    
    Dim Checked As Boolean
    
    
    
    Checked = True
    
    i = LBound(Condiciones) - 1
    
    Do
    
        i = i + 1
    
        For Each MyControl In Me.Controls
     
       
            If UCase(MyControl.Name) = Trim(UCase(Mid(Condiciones(i), 1, InStr(1, Condiciones(i), "=", vbTextCompare) - 1))) Then
            
            
                If Trim(UCase(Str(MyControl.Value))) <> Trim(UCase(Mid(Condiciones(i), InStr(1, Condiciones(i), "=", vbTextCompare) + 1, _
                                                            Len(Condiciones(i))))) Then
                                                            
                    Checked = False
                
                End If
                
            End If
            
        Next
        
        
    Loop Until (Not Checked) Or (i = UBound(Condiciones))
    
    CheckConditions = Checked
     
End Function

Thanks for any ideas!