Results 1 to 2 of 2

Thread: If statement

  1. #1
    Join Date
    Mar 2007
    Posts
    5

    Unanswered: If statement

    I have a form with 9 tabs. Each tab has a multiple questions and drop downs. I was trying to add new questions to a tab. I have the following code in the form.

    code:

    For x = 1 To TotQues
    Form("Drop" & x).Visible = False
    Form("Drop" & x).TabStop = False
    Form("Q" & x).value = Null
    Form("Pt" & x).Visible = False
    Next x

    Set rstlog = dbslog.OpenRecordset(sSql, dbOpenSnapshot)

    With rstlog
    For i = 1 To TotQues
    If rstlog.EOF Then
    For x = i To TotQues
    Form("Drop" & x).Visible = False
    Form("Drop" & x).TabStop = False
    Form("Q" & x).value = Null
    Next x
    Exit For
    End If
    If (i >= 1 And i <= 8 And !SecTitle = "Appraiser") Or _
    (i >= 9 And i <= 16 And !SecTitle = "Subject") Or _
    (i >= 17 And i <= 24 And !SecTitle = "Neighborhood") Or _
    (i >= 25 And i <= 32 And !SecTitle = "Site") Or _
    (i >= 33 And i <= 44 And !SecTitle = "Improvements") Or _
    (i >= 45 And i <= 70 And !SecTitle = "Sales Comparison") Or _
    (i >= 71 And i <= 78 And !SecTitle = "Value") Or _
    (i >= 79 And i <= 86 And !SecTitle = "Addendum") Or _
    (i >= 87 And i <= 102 And !SecTitle = "Other") Or _
    (i >= 103 And i <= 104 And !SecTitle = "Site") Then (This is the one I added newly)
    Form("Q" & i).value = !Question
    row = "SELECT ComboList FROM tbl_app_rev_combo where ComboNum = '" & !Combo & "' ORDER BY SrtOrd"
    Form("Combo_Option" & i).value = !Combo
    Form("drop" & i).RowSource = row
    Form("drop" & i) = !Default
    Form("Drop" & i).Visible = True
    Form("Drop" & i).TabStop = True
    Form("Pt" & i).Visible = True
    Form("Pt" & i) = !DefaultPts
    .MoveNext
    Else
    Form("Drop" & i).Visible = False
    Form("Drop" & i).TabStop = False
    Form("Pt" & i).Visible = False
    End If
    Next i
    End With

    My issue is I am able to see the Questions untill "Site" tab. The questions after this tab have disappeared. This is because after i = 104 it is not going back to i = 33 and so all the questions in other tabs are gone. Is there any solution for this. How do I rephrase this if statement?

    Thanks,

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Ok - after a long study of the code I'm fairly sure the answer lies in this bit of code - look closely at the two loops then tell me why it's not working!
    Code:
    For i = 1 To TotQues
    	If rstlog.EOF Then
    		For x = i To TotQues
    			Form("Drop" & x).Visible = False
    			Form("Drop" & x).TabStop = False
    			Form("Q" & x).value = Null
    		Next x
    Exit For
    	End If
    George
    Home | Blog

Posting Permissions

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