Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2006
    Posts
    17

    If / Then Error Message

    I have the following code in the After Update event of my combo box and the On Current event of my main form. If I try to open the main form, I get an error message that reads: "Compile error, Block If without End If" (it also highlights the End Sub in blue). If I take the code out of the main form, I still get the same message after an update to my combo box. What have I done wrong? :shock: :shock: :shock:

    Private Sub cboresponsetype_AfterUpdate()
    If Me.cboresponsetype = "A" Then
    Me.sbfAAdd.Visible = True
    Me.sbfBAdd.Visible = False
    Me.sbfCAdd.Visible = False


    Else
    If Me.cboresponsetype = "B" Then
    Me.sbfAAdd.Visible = False
    Me.sbfBAdd.Visible = True
    Me.sbfCAdd.Visible = False
    Else
    If Me.cboresponsetype = "C" Then
    Me.sbfAAdd.Visible = False
    Me.sbfBAdd.Visible = False
    Me.sbfCAdd.Visible = True
    End If
    End Sub

  2. #2
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    You're not getting the If blocks set up right. They need to be:


    Code:
    If <test> Then
        'code
    ElseIf <test> Then
        'code
    ElseIf <test> Then
        'code
    ElseIf <test> Then
        'code
    Else
        'code
    End If

  3. #3
    Join Date
    Mar 2006
    Posts
    17
    Thanks very much for more code illustration Patrick! I'll be checking this out tonight and will let you know how it goes


  4. #4
    Join Date
    Mar 2006
    Posts
    17
    You are correct Patrick! Now, do you also know how I can make all the subforms hidden when the main form opens, or before any updates are made?

    Thanks again---

  5. #5
    Join Date
    Dec 2005
    Location
    Wilmington, DE - USA
    Posts
    275
    In the Form's Open event you can make all of the subforms invisible. That's probably the easiest way...

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

Similar Threads

  1. FROM Clause error message
    By skylite in forum Queries
    Replies: 2
    Last Post: 10-23-2008, 05:47 AM
  2. Records deleted with NO warning message.
    By evanscamman in forum Access
    Replies: 2
    Last Post: 12-14-2007, 11:18 PM
  3. "Overflow" error message.
    By joeferraro2000 in forum Queries
    Replies: 0
    Last Post: 03-08-2007, 06:36 PM
  4. Inserting Picture in MS Access Message
    By wasim_sono in forum Programming
    Replies: 0
    Last Post: 01-17-2006, 03:46 AM
  5. Creating a *Good* Custom Message Box
    By Jerimiah33 in forum Forms
    Replies: 1
    Last Post: 11-09-2005, 04:47 PM

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 - Senior Forums