?
Solved

Issues with IF, THEN, ELSE statement in Visual Basic

Posted on 2008-09-29
4
Medium Priority
?
459 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
[X]
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
  • 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 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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