Access/Visual Basic help

Associate
Joined
15 Sep 2006
Posts
103
Location
Liverpool, UK
Hi,

I am having a bit of trouble with validation in Microsoft Access and Visual Basic. Basically, I have created some validation rules in Access (which work fine), and I have made a data environment in VB to link the two together. I go to add a record from within the UI I designed in VB, and I get a validation error (the custom one I set in Access) thrown back in my face.

For the StudentID (example StudentID would be "JONESP"), I have used a validation rule of:

Like "[A-Z][A-Z][A-Z][A-Z][A-Z][A-Z]" (which works fine in VB and Access).

For the StudentPostCode (example postcode would be: "L21 7TC") I have used a validation rule of:

Like "[A-Z]##[ ]#[A-Z][A-Z]" (which I get an error on in VB, even though it works find in Access)

Fort the StudentPhoneNumber (example phone number would be: "0151 2874012") I have used a validation rule of:

Like "####[ ]#######" (which I get an error with in VB, but again this works find in Access)

So I am a bit puzzled with the way in Access the data I enter conforms with the validation rules I set, but if I enter the same data in Visual Basic I get the validation error message I made thrown at me? This is confusing and happens for all the validation except for the StudentID - confusingly. So for some reason I am doubting that my validation rules are correct?

So can anyone help me with this please? Quickly if possible, as I do have a deadline to meet :)

Thank you very much kind Sir's :D
 
TrUz said:
I would scrap the rules in Access and use VB for all vaidation. You are going to have to validate it in VB before hand anyway, so you might as well only validate the once.

TrUz
How would I validate it in VB to achieve the same results though? I don't understand what you mean when you say I would have to validate it in VB before hand...

Cheers!
 
Ahh thank you! I will give it a go in a minute. By the way, is it advisable to have the same validation both in Access and VB?
 
Well I suppose I do not have to use validation, but I am much less familiar with input masks. I did have a look at them, and I did not like them.
 
Back
Top Bottom