Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Issues with IF, THEN, ELSE statement in Visual Basic

Posted on 2008-09-29
4
438 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 - Microsoft MVP, Access and Data Platform) 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

790 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