Results 1 to 3 of 3
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670

    Trouble With If Statements

    I keep getting an error of 'Block If w/o End If' but it looks to me like each one of my If statements has an Else and an End statement. What am I missing here that is causing the syntax to error?



    Code:
    Private Sub cmdbuttonOne_Click()
    'Declaring Variables
    Dim var1 As String, var2 As String, var3 As String
    Dim var4 As String, var5 As String, var6 As String
    Dim var7 As String, var8 As String, var9 As String
    
    
    'Capturing Variables
    If IsNull(Me!txtvar8) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar8.SetFocus
        Exit Sub
    Else
        var8 = Me.txtvar8.Text
    End If
    If IsNull(Me!txtvar9) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar9.SetFocus
        Exit Sub
    Else
        var9 = Me.txtvar9.Text
    End If
    If IsNull(Me!txtvar7) Then
        MsgBox ""Please A Valid Input", vbOKOnly
        Me.txtvar7.SetFocus
        Exit Sub
    Else
        var7 = Me.txtvar7.Text
    End If
    If IsNull(Me!txtvar1) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar1.SetFocus
        Exit Sub
    Else
        var1 = Me.txtvar1.Text
    End If
    If IsNull(Me!txtvar2) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar2.SetFocus
        Exit Sub
    Else
        var2 = Me.txtvar2.Text
    End If
    If IsNull(Me!txtvar3) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar3.SetFocus
        Exit Sub
    Else
        var3 = Me.txtvar3.Text
    End If
    If IsNull(Me!txtvar4) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar4.SetFocus
        Exit Sub
    Else
        var4 = Me.txtvar4.Text
    If IsNull(Me!txtvar5) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar5.SetFocus
        Exit Sub
    Else
        var5 = Me.txtvar5.Text
    End If
    If IsNull(Me!txtvar6) Then
        MsgBox "Please A Valid Input", vbOKOnly
        Me.txtvar6.SetFocus
        Exit Sub
    Else
        var6 = Me.txtvar6.Text
    End If
    
    
    End Sub

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    One End If missing! var4

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    670
    Quote Originally Posted by aytee111 View Post
    One End If missing! var4

    Dang - I thought I had them all! Thank you for pointing out the error in my ways!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. iif, then statements
    By frustratedwithaccess in forum Queries
    Replies: 1
    Last Post: 01-13-2015, 06:55 PM
  2. IIF() statements
    By ajetrumpet in forum Tutorials
    Replies: 0
    Last Post: 06-17-2011, 06:51 PM
  3. IIF statements?
    By staceyo in forum Queries
    Replies: 15
    Last Post: 09-28-2010, 08:45 AM
  4. IIF Statements
    By JDA2005 in forum Queries
    Replies: 8
    Last Post: 07-07-2009, 04:24 PM
  5. If statements
    By Ezeecopy in forum Access
    Replies: 0
    Last Post: 03-24-2009, 04:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums