Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2014
    Posts
    3

    Unanswered: Form controls refreshed programatically

    I have the rules that define what is visible and what color to paint the label and textbox of lots of objects on several forms stored in a hand full of tables. I am trying to reset the form in a procedure that loops through the rules, constructs the form control statement and runs it I think but it is not working. If I take the output and put it into my code I get the desired results but the procedure is not working. here is the code.

    Do While Not rstTabElem.EOF
    varControl = "Forms!" & rstTabElem!strParent & "!" & rstTabElem!strForm & "!" & rstTabElem!strElement
    'set the color
    If rstTabElem!intType <> 881 Then 'related element, just set visibility
    If rstTabElem!ynoRequired = -1 Then
    varValue = rstTabElem!strRequiredColor
    Else
    varValue = rstTabElem!strDefaultColor
    End If
    varEval = varControl & ".BackColor = " & varValue
    Debug.Print varEval
    Eval varEval
    End If
    'set visibility
    If rstTabElem!ynoDisplayed = -1 Then varValue = True Else varValue = False
    varEval = varControl & ".Visible = " & varValue
    Debug.Print varEval
    Eval varEval

    rstTabElem.MoveNext
    Loop


    varEval produces lots of statement like this

    Forms!frmMaster!subVisitResults!lblHoneywell_Appro val_Status__c.BackColor = RGB(255, 255, 255)
    Forms!frmMaster!subVisitResults!lblHoneywell_Appro val_Status__c.Visible = False
    Forms!frmMaster!subVisitResults!lblIncome_Verifica tion_Status__c.BackColor = RGB(255, 255, 255)


    which are all valid control statements. It appears like the eval statement is not doing what I want it to do which is execute the statement. What is the best way to make this happen. I need to change the visibility and color of lots of objects based on a dozen different visit types.

  2. #2
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    119
    Try something like this:
    I think this should work as long as varControl is dimmed as a control

    Do While Not rstTabElem.EOF
    varControl = Forms(rstTabElem!strParent)(rstTabElem!strForm)(rs tTabElem!strElement)
    'set the color
    If rstTabElem!intType <> 881 Then 'related element, just set visibility
    If rstTabElem!ynoRequired = -1 Then
    varValue = rstTabElem!strRequiredColor
    Else
    varValue = rstTabElem!strDefaultColor
    End If
    varControl.BackColor = varValue
    End If
    'set visibility
    If rstTabElem!ynoDisplayed = -1 Then varValue = True Else varValue = False
    varControl.Visible = varValue

    rstTabElem.MoveNext
    Loop
    Regards
    JD

    Software-Matters

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •