Require Data Entry?

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
 
B

Beetle

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
 
Y

Yula

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
 
B

Beetle

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top