MSaccess If ..Else. Compile Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benchpolo
    New Member
    • Sep 2007
    • 142

    MSaccess If ..Else. Compile Error

    Code:
    Private Sub cmdSaveRec_Click()
        If (Me.MemberID = "" Or IsNull(Me.MemberID)) Or _
            (Me.AppendDate = "" Or IsNull(Me.AppendDate)) Then MsgBox "MemberID is required!", vbCritical, "Validation Msg"
            Else
                DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
                DoCmd.GoToRecord , , acNewRec
                Me.MemberID.SetFocus
            End If
    End Sub
    When I ran compile from MS Access 2010, I get a compile error of Else without IF, but I do have the syntax coded correctly. please help.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Your stuff after the Then needs to be on a new line. Otherwise, that syntax is for a single line statement only.

    Comment

    • benchpolo
      New Member
      • Sep 2007
      • 142

      #3
      Code:
      Private Sub frmCapDeduct_Click()
         If Me.Check32.Value = "1" Then _
          Me.capdeduct.Value = "Y"
      End Sub
      You entered an expression that has no value.

      Thanks. I was able to figur it out.. Now a new issue arises ..
      I have a check box with Yes and No option. When the check box was set-up the value I assigned when Yes is selected is 1 and 0 for No. I want to pass a code on click in the frame when the Yes is selected "Y" would replace the 1 in my database and N for zero, but i am getting the error above when the click event occur. please advice. Thanks.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        This is a new question. Please create a new thread for it. We try to limit a thread to one question.

        Comment

        Working...