View Full Version : Unbound field


Haytham
01-13-2002, 10:02 AM
Hi All...
I have an Unbound Field in my form. Wil anybody tell me how to limit the entry to 11 figures only (No and not letters)..
It should be 11 exactly.
Thanks a lot.

Fornatian
01-13-2002, 11:33 AM
Wont setting the input mask to

00000000000

do it?

Ian

donbettis
01-13-2002, 12:08 PM
Haytham,

"Fornatian" is right setting the fields input mask to "00000000000" (Minus the ") should do the trick...

Another way you could achieve this is...

Place the following in your BeforeUpdate Event of the Field...

----Start Code----

dim lFieldLength
lFieldLength = 11
if len(me.[YourField]) <> lFieldLength then
MsgBox "Place Your Message Here"
end if

----End Code----

Personally...Fornatian's way will work better...

My Response was only meant to give you an option...


Hope This Helps...

Don

Haytham
01-13-2002, 01:15 PM
Hi .. Thank you for reply.
Well, the input mask will do the work well.
While, if I put the code, it gives me Compile Error.. Invalid Outside Procedure for thid code:lFieldLength = 11

One more thing please.. This field should not be blank. I put the code:
Docmd.cancelevent if no entry but still it passes smoothly.
I tried Exit Sub as well with the same result.
Will it be possible to do so and to limit the entry to figures only and not letters th' code...
Again thanks for your great help.

donbettis
01-13-2002, 04:50 PM
Haytham...

I am not sure why it's giving you a compile error...I typed the code in my first reply although I hadn't tested it at that time...I have used it in the past...I just cut and pasted the above code into an unbound field, changed the [YourField] part and, it worked fine on mine... I am not sure what version you are running... I have now tested the code on both access 2k and, access XP (a.k.a. access 2002).

The Code allowing you to pass on to the next field is one of the things I don't like about the code... This is where my statement "Personally...Fornatian's way will work better..." came from... As I said, the code was only meant as an option you could play with if needed...

Don

Fornatian
01-13-2002, 10:42 PM
Set the required property to Yes in table design or deal with the record entry in VBA in the before update event if you know how to use VBA.

Ian

Haytham
01-14-2002, 10:56 AM
donbettis, Hi .. Well I'm using A2k, still it's giving me compile error. I don't know why , I'll keep on trying.
Fornatian, thank you again. Unbound field has no base in table so no way to change its property to required.
Can I disable system msgbox and put mine..
Thanks both of you