Results 1 to 2 of 2

Thread: Returning control to original loop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    Houston, Texas - U.S.A.
    Posts
    84

    Question

    I have a list box of items in which the user can set up to 10 different tracking dates for each list item. The user can select one or any combination of items in the list box (multiple select), then click on one or several text boxes and enter a date. The date(s) will then be saved to a database. If one of the items selected has already been "dated and saved" and the user enters a different date, a form displays with all of the existing dates that differ from the new date. The user has the option through the use of check boxes to either overwrite the existing date (Yes check box) or not to overwrite the existing date (No check box). The code cycles through each date field looking for any dates that differ. As long as the user checks Yes on the displayed form, the code will return to the original loop and go to the next iteration. If the user checks No it will not go back to the original loop. My code is as follows:

    Original loop:
    Public Sub CheckIssueDates()

    Dim intSelected, intSelCount, I, J As Integer
    Dim strAccQuery As String

    intSelected = lstAllLines.ListCount
    intSelCount = 0
    For I = 0 To intSelected - 1
    If lstAllLines.Selected(I) Then
    intSelCount = intSelCount + 1
    strAccQuery = "SELECT * FROM IssueTypes WHERE LineNumber = '" _
    & lstAllLines.List(I) & "'"
    DB.OpenDB strAccQuery
    NullField.Value = DB.recRecordset("ToPipingCheck")
    arrDates(0) = NullField.IsNull
    NullField.Value = DB.recRecordset("FromPipingCheck")
    arrDates(1) = NullField.IsNull
    NullField.Value = DB.recRecordset("ToStress")
    arrDates(2) = NullField.IsNull
    NullField.Value = DB.recRecordset("FromStress")
    arrDates(3) = NullField.IsNull
    NullField.Value = DB.recRecordset("ToMTO")
    arrDates(4) = NullField.IsNull
    NullField.Value = DB.recRecordset("FromMTO")
    arrDates(5) = NullField.IsNull
    NullField.Value = DB.recRecordset("Hold")
    arrDates(6) = NullField.IsNull
    NullField.Value = DB.recRecordset("IFC")
    arrDates(7) = NullField.IsNull
    NullField.Value = DB.recRecordset("TransDate")
    arrDates(8) = NullField.IsNull
    NullField.Value = DB.recRecordset("IssueRelDate")
    arrDates(9) = NullField.IsNull
    DB.CloseDB
    For J = 0 To 9
    If arrDates(J) = "" Then
    If txtDates(J).Text <> "" Then
    DB.OpenDB strAccQuery
    DB.SaveThisIssueDate J
    DB.CloseDB
    End If
    End If
    If arrDates(J) <> "" Then
    If txtDates(J).Text <> "" And txtDates(J).Text <> _
    arrDates(J) Then
    frmDistDates.lblExistDates(J).Caption = arrDates(J)
    frmDistDates.lblLineNo.Caption = lstAllLines.List(I)
    frmDistDates.chkNo(J).Value = 1
    frmDistDates.Visible = True
    End If
    End If
    Next J
    End If
    Next I

    End Sub

    Loop behind "DistDates" form:

    Private Sub cmdOK_Click()

    Dim I As Integer
    Dim strAccQuery As String

    strAccQuery = "SELECT * FROM IssueTypes WHERE LineNumber = '" _
    & lblLineNo & "'"

    For I = 0 To 9
    If lblExistDates(I).Caption <> "" And chkYes(I).Value = 1 Then
    DB.OpenDB strAccQuery
    DB.SaveThisIssueDate I
    DB.CloseDB
    ElseIf lblExistDates(I).Caption <> "" And chkNo(I).Value = 1 Then
    frmDistDates.Visible = False
    End If
    Next I
    For I = 0 To 9
    lblExistDates(I).Caption = ""
    chkYes(I).Value = 0
    chkNo(I).Value = 0
    Next I
    frmDistDates.Visible = False
    frmStatusNotArea.CheckIssueDates

    End Sub

    I feel like I'm missing something very basic and simple but can't get it to work properly. Any ideas?

    [Edited by mgoarrow on 11-15-2000 at 02:37 PM]

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I haven't been looking at the details but instead looking for the most important part when it comes to raising events during loops.

    Now there shoud be a doevents statement in your original loop for them to occur. You could as well has other problems with the code but they might be harder to track without running the code.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

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



Click Here to Expand Forum to Full Width