Results 1 to 6 of 6

Thread: Visual Basic Compile Error: End If without block If

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19
    I keep getting this error during an on exit event in a form created in Access2000. Does anyone know what this error is and how to correct it?

    Thanks In Advance

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Omaha, Ne
    Posts
    65

    IF

    It means you tried to put and END IF and it does not have a matching IF statement above it. Try matching your IF and END IF 's up.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19
    Nias,

    Thanks for answering so quickly. However it is the only If statement I have and there is an if with the end if yet I still get this error.

    I am relatively new to VB and have never taken a formal class on the topic.

    My Library is limited and I am trying to learn Access2000 at the same time. Last version used was Access 2.0.

    Here is the Code I am running:
    Public Sub Business_Status_Exit(Cancel As Integer)
    If Business_Status = "Yes" Then Ma_Business_Info.show
    End If
    End Sub

    What I want to do is have a new access form open if Business_Status is = "Yes" else to nothing. Can you still help?

    Thanks again


  4. #4
    Lively Member
    Join Date
    Jan 2000
    Location
    Omaha, Ne
    Posts
    65
    Try putting the code behind the THEN statement on a line by itself.

    IF condition THEN
    do this
    ELSE
    do that
    END IF

  5. #5
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    Change your code to look like this:
    Public Sub Business_Status_Exit(Cancel As Integer)
    If Business_Status = "Yes" Then
    Ma_Business_Info.show
    End If
    End Sub

    I think your problem is that VB does not want an End IF if the entire if statement is on one line.

    You could also code it this way:
    Public Sub Business_Status_Exit(Cancel As Integer)
    If Business_Status = "Yes" Then Ma_Business_Info.show
    End Sub



  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19
    Thanks That was the problem.

    It still doesn't work but that error is gone.

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