Re: Changing field based on size

Tech-Archive recommends: Fix windows errors by optimizing your registry



Use the BeforeUpdate event procedure of the form to run the checks.

This example assumes you don't have to cope with the case where one of the
numbers is missing:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Height > Me.Length Then
Cancel = True
MsgBox "Height cannot be greater than Length."
End If
If Me.Height < Me.Width Then
Cancel = True
MsgBox "Height cannot be less than Width."
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mark" <Mark@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C48889BF-F82D-484B-9FC1-5E5414E0AFA6@xxxxxxxxxxxxxxxx
> Hope this insn't a double post the first didn't seem to go..
>
> I have data that shows the measurements of an item. The fields are:
>
> Length (L)
> Height (H)
> Width (W)
>
> Unfortunately our users can't seem to enter in the right data for the
> right
> field, meaning the Length might be in the Height field. I am unable to do
> the check during data entry since I am just linking to this table and not
> the
> owner.
>
> A constant in this is:
> Length will always be the largest
> Height will always be the middle
> Width will always be the smallest.
>
> How could I code this in vb to check and update this with out many if
> statements?


.


Quantcast