Solved

Issues with IF, THEN, ELSE statement in Visual Basic

Posted on 2008-09-29
4
422 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
ID: 22598363


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
ID: 22598372
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
ID: 22598430
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
ID: 31501256
Perfect, thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

863 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

21 Experts available now in Live!

Get 1:1 Help Now