LOOP Testing (True of False)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrel
    New Member
    • Nov 2006
    • 72

    #1

    LOOP Testing (True of False)

    Hi there i have a problem with the looping statement that i must use in order to achieve wha i want..

    Its like this i have a time scheduling system that compares records in a database the compare process is not a problem.

    if like this, what ive been compare is this:

    if combo1(x) = rs! "TimeStart and combo2(x) = rs!TimeEnd then

    txtCode.backcol or = vbred
    txtSubjects.bac kcolor = vbred
    MsgBox ("there's an error!"),vbCrit ical

    end if


    where: "x" is my counter dis is the code for my counter

    for x = 0 to 15


    Now, what i want to do is, to test first all the combo boxes that i have, before prompting the user the that schedule been made has an error on the previous records that are being save in my database.. and then highlight the schedule that has errors on it.

    Dont bother about the connection in my database, it is settle now, just concentrate on the loop... i dont have an idea on how to code those scenarios tat i want to do, whenever there an equal value on the database that i have.

    to summarized here what i want to do:

    1. test if theres an equal value of the combo boxes in my database(i know how to compare it, theres no problem in this area).

    2. after testing all the values, if theres an equal value, prompt the user that theres an error.

    3. highlight all the combo boxes that have errors.

    i hope you do understand what am trying to say...

    Thank you very much. any idea will help me to do this.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Here's some logic that might work (it's written in a sort of VB-inspired pseudo-code)...
    Code:
    Clear error flag
    For x = 0 To 15
      If combo(x) = rs(FieldName(x)) Then
        combo(x).BackColor = vbRed
        Set error flag
      Else
        combo(x).BackColor = vbWhite
      End If
    Next
    If error flag is set Then
      MsgBox "Oops!"
      Exit Sub
    End If
    Now go ahead - everything tested OK.

    Comment

    Working...