Group:  Microsoft Access ยป microsoft.public.access.forms
Thread: Validation on a form using properties

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

Validation on a form using properties
brlang[ at ]adelphia.net 29.09.2006 19:56:15
I have a box on a form that I am trying to validate the length of based
on a field in another form. I have tried using vb code but I get a
type match error or can not find the form if using the logic below. I
do not think that I have the right process in the code as I am new to
this. Code I have used in the beforeupdate is below:

Private Sub key2_BeforeUpdate(Cancel As Integer)

Lengthoffield = Len(Me.[key2])
If Lengthoffield > Forms![qry_key definitions]![key_key2_len] Then
MsgBox "You have entered information that is too long for the
field."
Cancel = True
End If
End Sub

Re: Validation on a form using properties
Steve Schapel <schapel[ at ]mvps.org.ns> 30.09.2006 18:53:37
Brlang,

First point is that you do not seem to have declared the Lengthoffield
variable. I would have expected to see something like this at the
beginning of the procedure...
Dim Lengthoffield As Integer

Second point is that the qry_key_definitions form needs to be open at
the time when you are running this procedure. Is this the case?

--
Steve Schapel, Microsoft Access MVP

brlang[ at ]adelphia.net wrote:
[Quoted Text]
> I have a box on a form that I am trying to validate the length of based
> on a field in another form. I have tried using vb code but I get a
> type match error or can not find the form if using the logic below. I
> do not think that I have the right process in the code as I am new to
> this. Code I have used in the beforeupdate is below:
>
> Private Sub key2_BeforeUpdate(Cancel As Integer)
>
> Lengthoffield = Len(Me.[key2])
> If Lengthoffield > Forms![qry_key definitions]![key_key2_len] Then
> MsgBox "You have entered information that is too long for the
> field."
> Cancel = True
> End If
> End Sub
>

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