Results 1 to 4 of 4

Thread: EndIF without IF

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    102

    EndIF without IF

    can Anyone find the error here.

    I keep on getting the Endif without If error but I cant find the error

    Code:
    Private Sub cmbpay_Click()
    'This proc will run when the client clicks on delivery combobox.
    'Once the client selects their option then
    'the textboxes will be filled with the details of the required
    'credit card option. These textboxes will then be locked.
        Dim i As Integer
        adodel.RecordSource = "PaymentMethods"
        adodel.Refresh
        With adodel.Recordset
            .MoveFirst
            Do While Not .EOF
    'If clientID is found and text from combobox matches the data on field CardType
                If cmbpay.Text = .Fields("ClientCardType") And .Fields("ClientID") = frmShopWindow.ID Then
                    txtpay(1).Text = cmbpay.Text
                    txtpay(2).Text = .Fields("ClientCardNo")
                    CmbDate(0).Text = GetMonth(Mid$((.Fields("ClientCardStartDate")), 1, 2))
                    CmbDate(1).Text = Right$(.Fields("ClientCardStartDate"), 4)
                    CmbDate(2).Text = GetMonth(Mid$((.Fields("ClientCardExpiryDate")), 1, 2))
                    CmbDate(3).Text = Right$(.Fields("ClientCardExpiryDate"), 4)
                    DoEvents
                    If Date > CDate("01/" & GetMonthNumber(CmbDate(0)) & "/" & CmbDate(1)) Then
                        If Date < CDate("01/" & GetMonthNumber(CmbDate(2)) & "/" & CmbDate(3)) Then
                            txtpay(2).Enabled = False
                            Cmdnewpay.Visible = False
                            cmbpay.Enabled = False
                            For i = 0 To CmbDate.Count - 1
                                CmbDate(i).Enabled = False
                            Next i
                            If txtdel(2).Enabled = False And txtpay(2).Enabled = False Then CmdFinish.Visible = True
                                Exit Sub
                            End If
                        Else
                            Call showError(CmbDate(2), "Invalid Expiry Date")
                            Exit Sub
                        End If
                    Else
                        Call showError(CmbDate(0), "Invalid Start Date")
                        Exit Sub
                    End If
                End If
                .MoveNext
            Loop
        End With
    End Sub

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    102
    Found it Sorry

  3. #3
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    VB Code:
    1. If txtdel(2).Enabled = False And txtpay(2).Enabled = False Then CmdFinish.Visible = True
    2.             Exit Sub
    3. End If


    by the way, did you know that

    for I=1 to 20
    Next I

    is slower than

    for I=1 to 20
    Next

    ?
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  4. #4
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    the statement

    If txtdel(2).Enabled = False And txtpay(2).Enabled = False Then CmdFinish.Visible = True

    is selfcontained and does not require (or allow) any "end if" since you've completed the if all on one line.

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