Code to show data in txt boxes

anb001

Registered User.
Local time
Today, 17:18
Joined
Jul 5, 2004
Messages
197
I have a form with 2 combos, 6 txt boxes and 1 cmd button.

When a user click the cmd button, the 6 txt boxes should show data from a table, which corresponds to what is entered/chosen in both combos. If a combination in the 2 combos is not available, a msgbox should pop up stating same, and if a user only use one combo, a msgbox should also state that both combos should be used.

So far I'm only able to show data in the txt boxes based on 1 combo (see code below). I would appreciate any help you might have.
-----------------------
Private Sub cmdServiceFind_Click()

Forms!frmservice.txtMax20cap = DLookup("Max20Capacity", "tblServiceRestriction", "Service='" & Forms!frmservice.cboServiceCombo.Column(0) & "'")

'(Above line is made for each textbox)

End sub
 
anb,

Code:
Private Sub cmdServiceFind_Click()

If IsNull(Me.cboServiceCombo) Or IsNull(Me.cboOtherCombo) Then
   MsgBox("Please fill in both.")
   Exit Sub
End If

Me.txtMax20cap = Nz(DLookup("Max20Capacity", _
                            "tblServiceRestriction", _
                            "Service = '" & Me.cboServiceCombo.Column(0) & "' And " & _
                            "Other   = '" & Me.cboOtherCombo.Column(0) & "'"), "")

End sub

Wayne
 

Users who are viewing this thread

Back
Top Bottom