?
Solved

Issues with IF, THEN, ELSE statement in Visual Basic

Posted on 2008-09-29
4
Medium Priority
?
474 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 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

850 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