By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,052 Members | 1,456 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,052 IT Pros & Developers. It's quick & easy.

MSaccess If ..Else. Compile Error

benchpolo
100+
P: 142
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSaveRec_Click()
  2.     If (Me.MemberID = "" Or IsNull(Me.MemberID)) Or _
  3.         (Me.AppendDate = "" Or IsNull(Me.AppendDate)) Then MsgBox "MemberID is required!", vbCritical, "Validation Msg"
  4.         Else
  5.             DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  6.             DoCmd.GoToRecord , , acNewRec
  7.             Me.MemberID.SetFocus
  8.         End If
  9. 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.
Jun 11 '12 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,366
Your stuff after the Then needs to be on a new line. Otherwise, that syntax is for a single line statement only.
Jun 12 '12 #2

benchpolo
100+
P: 142
Expand|Select|Wrap|Line Numbers
  1. Private Sub frmCapDeduct_Click()
  2.    If Me.Check32.Value = "1" Then _
  3.     Me.capdeduct.Value = "Y"
  4. 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.
Jun 12 '12 #3

Rabbit
Expert Mod 10K+
P: 12,366
This is a new question. Please create a new thread for it. We try to limit a thread to one question.
Jun 12 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.