Require Data Entry?

  • Thread starter Thread starter Yula
  • Start date Start date
Y

Yula

I Have a field where the user selects Paper Type. If they select a certain
type they must enter in another field the length. I have trying to figure out
how to do this and I have no clue. Can somesome please advise?

Table: Paper Lookup
Paper Description
Paper Rate
Paper Square Foot

Form:
Combobox: Paper - they select Foam (Foam has an X in the table)
Text box: Length
Textbox: Width

If Paper square foot has an X, require date entry in field Length and Width


Thanks so much,
Yula
 
You could add the square foot field to the row source of your combo
box. For this example I'll assume that it is column 2 in the row source
(which would actually be the third column, as it is a zero based index).

Then, in the Before Update event of your form you would put something
like;

Private Sub Form_BeforeUpdate (Cancel As Integer)

If Me.MyCombo.Column(2) = "X" Then
If nz(Me.txtLength, "")="" Then
MsgBox "You must enter a length"
Cancel = True
ElseIf nz(Me.txtWidth,"")="" Then
MsgBox "You must enter a width"
Cancel = True
End If
End If

End Sub
 
Beetle: If I add the square foor field in the combo box, the user can see it
when they click the drop down. I want the user to select the description and
if they select the description that has the X in the Square Foot field, it
would automatically require them to enter data in the Width and Length txt
boxes.

Thanks again,
Yula
 
Set the column width to 0 for that column. Then the users won't see it
but you can still reference it by using the column method.

Another method would be to use DLookup

Private Sub Form_BeforeUpdate (Cancel As Integer)

If DLookup("SquareFoot", "PaperTable", "PaperDescription=""" & Me.MyCombo &
"""")="X" Then
If nz(Me.txtLength, "")="" Then
MsgBox "You must enter a length"
Cancel = True
ElseIf nz(Me.txtWidth,"")="" Then
MsgBox "You must enter a width"
Cancel = True
End If
End If

End Sub

Note: the Dlookup syntax should be all on one line. IMO the combo box column
method is easier and faster.
 
Back
Top