Solved

Issues with IF, THEN, ELSE statement in Visual Basic

Posted on 2008-09-29
4
410 Views
Last Modified: 2013-11-27
I am trying to apply a very simple IF THEN ELSE statement to my VB code to send an email  (The code runs fine without the IF THEN ELSE statement)

The IF part will be "IF value is null then end program"

The Else will be to run the code and send the email like normal but once I add the If statement it says "compile error: else without if" but there is an "IF" and an "END IF" statement in the code.

Can someone tell me what I am doing wrong? (Also there is no IF statements in the "send email" code)
Private Sub ImpBy_AfterUpdate()

If Me.ImpBy = Null Then End

Else

'EMAIL SEND PROGRAM GOES HERE, I LEFT THIS OUT TO MAKE THIS LOOK SIMPLE.

End If

End Sub

Open in new window

0
Comment
Question by:filtrationproducts
  • 2
4 Comments
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility


Private Sub ImpBy_AfterUpdate()
If IsNull(Me.ImpBy)  Then End
Else
'EMAIL SEND PROGRAM GOES HERE, I LEFT THIS OUT TO MAKE THIS LOOK SIMPLE.
End If
End Sub
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 75 total points
Comment Utility
Just for good measure:

Private Sub ImpBy_AfterUpdate()
If IsNull(Me.ImpBy)  Then
    ' do what ever
Else
'EMAIL SEND PROGRAM GOES HERE, I LEFT THIS OUT TO MAKE THIS LOOK SIMPLE.
End If

End Sub
0
 
LVL 8

Expert Comment

by:MatthiasVance
Comment Utility
You need to move the statement after your Then to a different line, like this.

Kind regards,

Matthias Vance

Private Sub ImpBy_AfterUpdate()

If Me.ImpBy = Null Then

End

Else

'EMAIL SEND PROGRAM GOES HERE, I LEFT THIS OUT TO MAKE THIS LOOK SIMPLE.

End If

End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:filtrationproducts
Comment Utility
Perfect, thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now