Do Nothing please help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help with if then else

What statement must I put in my code to "do nothing" if a criteria is met?

Thanks

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...-acb7-572d655bab87&dg=microsoft.public.access
 
Help with if then else

What statement must I put in my code to "do nothing" if a criteria is met?

Thanks

To do nothing... do nothing.

If <some condition> Then
<do something
Else
End If

Just no statement at all - or you can leave off the Else and just put the End
If.

You'll have to explain the context though. Is this in VBA code (which has
statements and code) or in a Query (which has criteria)?


John W. Vinson [MVP]
 
You don't have to put anything.

You can code:
If Me.City = "New York" Then
Else
MsgBox "It's not New York"
End If

That's equivalent to:
If Me.City <> "New York" Or IsNull(Me.City) Then
MsgBox "It's not New York"
End If

If the handling of Null is not familiar, this may help:
Common errors with Null
at:
http://allenbrowne.com/casu-12.html

You might like to add a comment between the If and Else lines, to indicate
that the (seemingly) missing line is not a coding mistake.
 
Back
Top