IF statements

  • Thread starter Thread starter Mikey May
  • Start date Start date
M

Mikey May

I am currently developing some VB Code for procedures
within my department.

I am having some trouble with a piece of code that SHOULD
work but doesn't and I can't seem to work out why. If
anyone can help me with this it would be greatly
appreciated.

I have an input box asking for various bit of data, 1 bit
of data is an account reference ('AccRef' in code) this
reference will be 3 alpha and 5 numerical characters eg
LGD12345. I want to check that the first 2 digit are 'LG'
and have the following code to do this -

If Left(AccRef, 2) = "lg" Then
MsgBox "has 8 and LG at start"
Else
MsgBox "has 8 but no LG at start"
End If

This code always brings up "has 8 but no LG" ie 8
characters but LG is not the prefix!

It is probably something very simple, but can't see why
yet.

Once I have solved this I want to make sure that the 3
digit is alpha and not numerical, I assume I am going to
have the same problem again!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top