Results 1 to 3 of 3
  1. #1
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43

    Compile errer: "Else without If" in second line

    I get the above error when an AfterUpdate-event is executing this code:
    Code:
    If Me.MedicalTreatmentType = 1 Then Me.MedicalTreatmentFrequence.Enabled = True & Me.MedicalTreatmentAntiarrhythmics.Enabled = False & Me.MedicalTreatmentOther.Enabled = False
    ElseIf Me.MedicalTreatmentType = 2 Then Me.MedicalTreatmentFrequence.Enabled = False & Me.MedicalTreatmentAntiarrhythmics.Enabled = True & Me.MedicalTreatmentOther.Enabled = False
    Else: Me.MedicalTreatmentFrequence.Enabled = False & Me.MedicalTreatmentAntiarrhythmics.Enabled = False & Me.MedicalTreatmentOther.Enabled = True
    End If
    The error is in the second line.
    What am I doing wrong?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I think your internal & (which is a concatenation symbol) is in error

    Try (untested)
    Code:
    If Me.MedicalTreatmentType = 1 Then
        Me.MedicalTreatmentFrequence.Enabled = True _
        Me.MedicalTreatmentAntiarrhythmics.Enabled = False  
        Me.MedicalTreatmentOther.Enabled = False
    ElseIf Me.MedicalTreatmentType = 2 Then 
        Me.MedicalTreatmentFrequence.Enabled = False _
        Me.MedicalTreatmentAntiarrhythmics.Enabled = True  
        Me.MedicalTreatmentOther.Enabled = False
    Else
        Me.MedicalTreatmentFrequence.Enabled = False 
        Me.MedicalTreatmentAntiarrhythmics.Enabled = False 
        Me.MedicalTreatmentOther.Enabled = True
    End If

  3. #3
    trolleri is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    43
    Hm, that simple - thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 10-02-2013, 01:02 PM
  2. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  3. "Not" criteria works for one line, but not two
    By avarusbrightfyre in forum Queries
    Replies: 1
    Last Post: 02-02-2012, 10:56 AM
  4. Replies: 5
    Last Post: 12-06-2010, 10:15 AM
  5. Replies: 1
    Last Post: 10-19-2009, 02:37 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