Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo dependant upon 2 other combos

Status
Not open for further replies.

Joshua61679

Technical User
Dec 28, 2001
36
US
I've got a form with 3 fields, all combo boxes: cmbType, cmbSupplier and cmbPart. I currently have cmbSupplier dependant upon cmbType. I'd like to make cmbPart dependant upon both cmbType and cmbSupplier. I have a query set up, but I'm not sure how to code it. My code to make cmbSupplier dependant is:
Code:
Private Sub cmbSupplier_GotFocus()
    If Len(Trim(Nz(cmbType, "") & "")) = 0 Then
        MsgBox "Please Specify Type First"
        cmbType.SetFocus
    Else
        cmbSupplier.Requery
    End If
End Sub
I'm not sure how to convert this to make it work to check two combo boxes at once though. I've tried just doubling it and making the neccessary nominclature changes:
Code:
Private Sub cmbPart_GotFocus()
    If Len(Trim(Nz(cmbSupplier, "") & "")) = 0 Then
        MsgBox "Please Specify Supplier First"
        cmbSupplier.SetFocus
    Else
        cmbPart.Requery
    End If
    
     If Len(Trim(Nz(cmbType, "") & "")) = 0 Then
        MsgBox "Please Specify Type First"
        cmbType.SetFocus
    Else
        cmbPart.Requery
    End If
End Sub
I had little hope that this would work, and it doesn't. I seems to only work to check the first part (cmbSupplier). Any help would be much appreciated.

-Josh
 
Try this:
Code:
Private Sub cmbPart_GotFocus()
    If [COLOR=blue]([/color]Len(Trim(Nz(cmbSupplier, "") & "")) = 0 [COLOR=blue]) OR (Len(Trim(Nz(cmbType, "") & "")) = 0) [/color] Then
        MsgBox "Please Specify Supplier and Type First"
        cmbSupplier.SetFocus
    Else
        cmbPart.Requery
    End If
    
End Sub

HTH
Lightning
 
Private Sub cmbPart_GotFocus()
If Len(Trim(Nz(cmbSupplier, "") & "")) = 0 Then
MsgBox "Please Specify Supplier First"
cmbSupplier.SetFocus
ElseIf Len(Trim(Nz(cmbType, "") & "")) = 0 Then
MsgBox "Please Specify Type First"
cmbType.SetFocus
Else
cmbPart.Requery
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I got both these to work, thanks for the help!

-Joshua
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top