Results 1 to 2 of 2
  1. #1
    h3nno is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    3

    Else without IF

    Hi,

    I am currently receiving the error "Else without IF" on line "ElseIf QC2 = -1 Then".

    Code:
    Dim QC1 As Integer
    Dim QC2 As Integer
    Dim QC3 As Integer
    Dim QC4 As Integer
    
    
    QC1 = DLookup("LoggedIn", "tbl_Users", "[Username] = 'QC_AM1' or [Username] = 'QC_PM1'")
    QC2 = DLookup("LoggedIn", "tbl_Users", "[Username] = 'QC_AM2' or [Username] = 'QC_PM2'")
    QC3 = DLookup("LoggedIn", "tbl_Users", "[Username] = 'QC_AM3' or [Username] = 'QC_PM3'")
    QC4 = DLookup("LoggedIn", "tbl_Users", "[Username] = 'QC_AM4' or [Username] = 'QC_PM4'")
    
    
    
    
    If QC1 = -1 Then
        frm_QCQueue.lblQC1.Caption = "Quality Control one: Logged in"
        frm_QCQueue.lblQC1.ForeColor = vbGreen
    Else
        frm_QCQueue.lblQC1.Caption = "Quality Control one: Not logged in"
        frm_QCQueue.lblQC1.ForeColor = vbRed
    
    
    ElseIf QC2 = -1 Then
        frm_QCQueue.lblQC2.Caption = "Quality Control one: Logged in"
        frm_QCQueue.lblQC2.ForeColor = vbGreen
        
    ElseIf QC2 = 0 Then
        frm_QCQueue.lblQC2.Caption = "Quality Control one: Not logged in"
        frm_QCQueue.lblQC2.ForeColor = vbRed
    
    
    
    
    ElseIf QC3 = -1 Then
        frm_QCQueue.lblQC3.Caption = "Quality Control one: Logged in"
        frm_QCQueue.lblQC3.ForeColor = vbGreen
    Else
        frm_QCQueue.lblQC3.Caption = "Quality Control one: Not logged in"
        frm_QCQueue.lblQC3.ForeColor = vbRed
        
    
    
    ElseIf QC4 = -1 Then
        frm_QCQueue.lblQC4.Caption = "Quality Control one: Logged in"
        frm_QCQueue.lblQC4.ForeColor = vbGreen
    Else
        frm_QCQueue.lblQC4.Caption = "Quality Control one: Not logged in"
        frm_QCQueue.lblQC4.ForeColor = vbRed
    
    
    End If


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Only the last Else in an If Then ElseIf series can omit the If. I think you need 4 independent If Then Else structures.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

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