Cascading Combo Subform Tied to Parent

G

Guest

I'm trying to get a cascading combo box in my subform to tie to a combo box
in my parent form. What am I missing???

Private Sub cboSupply()
On Error Resume Next
cboSupply.RowSource = "Select DISTINCT tblSupply.SUPPLYNAME " & _
"FROM tblSupply " & _
"WHERE tblSupply.SUPPLIERNAME = '" & Parent.[cboSupplier] & "' " & _
"ORDER BY tblSupply.SUPPLYNAME;"
End Sub

Thank you.
 
D

Douglas J. Steele

What happens when you run that code?

Does Parent.[cboSupplier] return what you think it does? (In other words,
you seem to be expecting a name: is that what it returns?)
 
G

Guest

I'm setting up a purchase order w/ the Supply Name, $, and quantity ordered
in the subform and the Supplier Name in the Parent form. I only want to see
an individual Suppliers supplies.

What happens when I run this, is the supply combo box doesn't limit the
supplies to the particular supplier.


Douglas J. Steele said:
What happens when you run that code?

Does Parent.[cboSupplier] return what you think it does? (In other words,
you seem to be expecting a name: is that what it returns?)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim said:
I'm trying to get a cascading combo box in my subform to tie to a combo
box
in my parent form. What am I missing???

Private Sub cboSupply()
On Error Resume Next
cboSupply.RowSource = "Select DISTINCT tblSupply.SUPPLYNAME " & _
"FROM tblSupply " & _
"WHERE tblSupply.SUPPLIERNAME = '" & Parent.[cboSupplier] & "' " &
_
"ORDER BY tblSupply.SUPPLYNAME;"
End Sub

Thank you.
 
G

Guest

I don't get the Supply combo box in the subform to limit the supply to the
Supplier.

I am trying to build a form for Purchase orders where the Supplier appears
in the parent form and the Supply, $, and Quantity ordered appear in the
subform. I want the supply combo box to be limited to the supplies the
supplier in the parent form supplys.

Thank you.

Douglas J. Steele said:
What happens when you run that code?

Does Parent.[cboSupplier] return what you think it does? (In other words,
you seem to be expecting a name: is that what it returns?)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim said:
I'm trying to get a cascading combo box in my subform to tie to a combo
box
in my parent form. What am I missing???

Private Sub cboSupply()
On Error Resume Next
cboSupply.RowSource = "Select DISTINCT tblSupply.SUPPLYNAME " & _
"FROM tblSupply " & _
"WHERE tblSupply.SUPPLIERNAME = '" & Parent.[cboSupplier] & "' " &
_
"ORDER BY tblSupply.SUPPLYNAME;"
End Sub

Thank you.
 
D

Douglas J. Steele

And the answer to my question about what Parent.[cboSupplier] returns
is....?

Try the following:

Private Sub cboSupply()
On Error Resume Next

Dim strSQL As String

strSQL = "Select DISTINCT tblSupply.SUPPLYNAME " & _
"FROM tblSupply " & _
"WHERE tblSupply.SUPPLIERNAME = '" & Parent.[cboSupplier] & "' " & _
"ORDER BY tblSupply.SUPPLYNAME;"

Debug.Print strSQL

cboSupply.RowSource = strSQL

End Sub

Go to the Immediate Window (Ctrl-G) and look at what's printed for strSQL.
Paste it back here.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Tim said:
I don't get the Supply combo box in the subform to limit the supply to the
Supplier.

I am trying to build a form for Purchase orders where the Supplier appears
in the parent form and the Supply, $, and Quantity ordered appear in the
subform. I want the supply combo box to be limited to the supplies the
supplier in the parent form supplys.

Thank you.

Douglas J. Steele said:
What happens when you run that code?

Does Parent.[cboSupplier] return what you think it does? (In other words,
you seem to be expecting a name: is that what it returns?)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Tim said:
I'm trying to get a cascading combo box in my subform to tie to a combo
box
in my parent form. What am I missing???

Private Sub cboSupply()
On Error Resume Next
cboSupply.RowSource = "Select DISTINCT tblSupply.SUPPLYNAME " & _
"FROM tblSupply " & _
"WHERE tblSupply.SUPPLIERNAME = '" & Parent.[cboSupplier] & "' "
&
_
"ORDER BY tblSupply.SUPPLYNAME;"
End Sub

Thank you.
 

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