Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009

    Unanswered: Checking values, changing labels

    I have about 20 forms in my db - each one is a psychological assessment with anywhere from 10 - 50 questions. I would like to be able to check to make sure that at the end of each form the user has responded to every question. If the user has not answered a question, I would like the font on the corresponding label to turn red to alert the user to which questions still need to be answered. For example....

    if opg14.value = "" then
    lbl14.forecolor = 255

    I've tried using a for statement for all controls on the form but I can't implement it. Any help would really be appreciated.

    Thank you.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    place the code in the forms before update event
    set cancel = true if there isn't a value, and set the backgorund colour of label which is invalid. I'd also suggest you display a message box saying why they cannot save the record at that time.

    there are other design metaphors, one is when you add a new record display a mark alongside questions that require answers. as each section is completed the mark goes away or is replaced. I've quite often used a red cross and green tick
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2009
    Thanks - the thing is I have over 500 variables so I would like to use a loop to do this instead of coding each individually. I've been trying something like this:

    Dim ctl As Control

    For Each ctl In Me.Controls
    Select Case ctl.ControlType
    Case acTextBox, acComboBox, acListBox, acCheckBox, acOptionGroup
    If IsNull(ctl.Value) Then


    End If
    Case Else
    End Select
    Next ctl

    This is not bad if I just wanted to change say the border of the input field and I'm ok if this is all I can do.... but ideally I would like to change the font color of the corresponding label of each question. I though about doing a While loop to cycle through all the control values e.g. opg1.value, opg2.value, opg3.value, etc and then change lbl1.forecolor, lbl2.forecolor, etc

    I had a hard time coding that though.

Posting Permissions

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