Group:  Microsoft Access ยป microsoft.public.access.gettingstarted
Thread: Access question

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Access question
"CalBerkleyTekkie" <andrew.menendez[ at ]raymondjames.com> 29.09.2006 19:34:23
Hopefully this will be easy for some people.

I'm trying to write an If statement in VBA for access, however I think
I am formatting it wrong. What I am logically trying to do is this: If
the first 6 numbers in this given field does not equal 000001 or
000002, then carry out the rest of the function. Currently I have it
formatted like this:

If IdentificationNumber <> 000001 Or IdentificationNumber <> 000002
Then

Any suggestions? Thanks!

-Jimmy

Re: Access question
"John Spencer" <spencer[ at ]chpdm.edu> 29.09.2006 20:28:02
Assuming that the field is a text field (otherwise leading zeroes would be
irrelevant), try

IF Left(IdentificationNumber,6) <> "000001" AND
Left(IdentificationNumber,6) <> "000002" Then
'Do something here
End IF

Note the use of AND instead of OR. Your boolean logic would have run the
code every time. Since if the value is 000001 then it is by definition not
000002. And vice versa for 000002. And of course any other value would be
true for both parts of the if statement.


"CalBerkleyTekkie" <andrew.menendez[ at ]raymondjames.com> wrote in message
news:1159558463.633627.175590[ at ]e3g2000cwe.googlegroups.com...
[Quoted Text]
> Hopefully this will be easy for some people.
>
> I'm trying to write an If statement in VBA for access, however I think
> I am formatting it wrong. What I am logically trying to do is this: If
> the first 6 numbers in this given field does not equal 000001 or
> 000002, then carry out the rest of the function. Currently I have it
> formatted like this:
>
> If IdentificationNumber <> 000001 Or IdentificationNumber <> 000002
> Then
>
> Any suggestions? Thanks!
>
> -Jimmy
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net