vendredi 10 avril 2020

MS Access 'Compile Error: Else without if' : I'm a newbie but code looks correct am I missing something?

For the life of me I can't find an issue with this code. Access keeps telling me there is a "compile error else without if". When I go to debug, it stops on the Elseif line and highlights 'me.cboKillRemaining'.

I tried to read about some others having the same problem and they all seemed to involve loops. I do have a loop that runs below but I think this problem is self contained in my code below. I also read someone whom fixed a similar problem by using a variant rather than a string variable and using 'set', but I get the same compile error when trying that.

Please help!

Dim Result As String
Dim Path As String

    'Determine path
    If (IsNull(Me.cboKillRemaining) Or Me.cboKillRemaining = "No") And Me.txtRemClones > 0 Then
        Result = MsgBox("Create " & Me.txtNumofTags & " tags from " & Me.cboGroup & " and leave remaining " & Me.txtRemClones & " clones active?", vbYesNo, "Confirm transplant")
        If Result = vbYes Then Path = 1
        Else: Path = 4
        End If

    ElseIf Me.txtRemClones > 0 And Me.cboKillRemaining = "Yes" Then
        Result = MsgBox("Create " & Me.txtNumofTags & " tags from " & Me.cboGroup & ", kill remaining " & Me.txtRemClones & ", and inactivate clone group?", vbYesNo, "Confirm transplant")
        If Result = vbYes Then Path = 2
        Else: Path = 4
        End If

    Else 'None remaining do not need to ask to kill clones
        Result = MsgBox("Create " & Me.txtNumofTags & " tags from " & Me.cboGroup & " and inactivate clone group?", vbYesNo, "Confirm transplant")
        If Result = vbYes Then Path = 3
        Else: Path = 4
        End If
    End If

Aucun commentaire:

Enregistrer un commentaire