Hidden Fields

Lex

Registered User.
Local time
Today, 14:04
Joined
Jan 7, 2003
Messages
11
I wish to hide a field and only make it seen if they order over 50 of one item then i wish to make the new field requiered.

on my table I have

Order Amount:
Order Comment:

plus several other fields, but the order comment field I do not want to see on a form unless the order amount field has a number greater then 49 in it, then i wish for it tobecome visiable and required
 
Have a hidden textbox on your form, and on the Quantity textbox's AfterUpdate() event check if the value is greater than 49 and then make the hidden textbox visible.

Basically:

Code:
Private Sub txtQuantity_AfterUpdate()
   If Me.txtQuantity > 49 Then
      txtHiddenNotes.Visible = True
   Else
      txtHiddenNotes.Visible = False
   End If
End Sub
 
Then in the BeforeUpdate event of the FORM, you need to make sure something was entered in the comment field.

If Me.txtQuantity > 49 and Len(Trim(Me.txtHiddenNotes.Visible)) = 0 Then
Me.txtHiddenNotes.SetFocus
Cancel = True
Msgbox "You must enter a comment before you can save the record",vbOKOnly
End If

You also need to decide what you want to do if the quantity field is > 50 thereby allowing a comment to be entered, but the quantity is changed to something less than 50 before the record is saved. This leaves something of a data anomoly. A value of less than 50 in the quantity field and also some value in the comments field.
 

Users who are viewing this thread

Back
Top Bottom