Requery Method

A

AlanW

I have referred to the website http://www.mvps.org/access/forms/frm0028.htm
in order to limit the content of Combo box “Product†after selecting the
content of Combo box “Supplierâ€. Both the field “supplier†and “ productâ€
are included in a table named “Supplierâ€

But it does not work. Could someone please help.

The code is listed below:-

Private Sub Supplier_AfterUpdate()
Dim strSQL As String
strSQL =â€Selectâ€& Me!Supplier
strSQL = strSQL & “Supplier!Supplierâ€
Me!Product.RowSourceType =†Table/Queryâ€
Me!Product.RowSource = strSQL
End Sub
 
M

Marshall Barton

AlanW said:
I have referred to the website http://www.mvps.org/access/forms/frm0028.htm
in order to limit the content of Combo box “Product” after selecting the
content of Combo box “Supplier”. Both the field “supplier” and “ product”
are included in a table named “Supplier”

But it does not work. Could someone please help.

The code is listed below:-

Private Sub Supplier_AfterUpdate()
Dim strSQL As String
strSQL =”Select”& Me!Supplier
strSQL = strSQL & “Supplier!Supplier”
Me!Product.RowSourceType =” Table/Query”
Me!Product.RowSource = strSQL
End Sub


Co7uld you try to post your question in plain text instead
whatever you're using to format you message. I can quite
separate the junk from your message.
 
B

Brian Bastl

Hi Alan,
Both the field "supplier" and " product"
are included in a table named "Supplier"

They shouldn't both be in the Suppliers table; Suppliers belong there.
Products belong in their own table. And then there should be a third table:
SuppliersProducts which matches the supplier with their products.

That said, using your current table structure, your rowsource would look
like:

Private Sub Supplier_AfterUpdate()

Dim strSQL as String

strSQL = "SELECT Products FROM Supplier Where Supplier ='" & Me.Supplier
& "'"

Me!Product.RowSourceType =" Table/Query"

Me!Product.RowSource = strSQL

End Sub

Brian
 
B

Brian Bastl

Oops, changed Product to Products inadvertantly. revisions below.

' assume Supplier is text
strSQL = "SELECT Product FROM Supplier Where Supplier ='" & Me.Supplier
& "'"

' if Supplier is number then:
strSQL = "SELECT Product FROM Supplier Where Supplier =" & Me.Supplier

Brian
 
J

Jessica

Hi Brian,

THANKS SO MUCH for that post, my coworker and I have been tying to figure
that out for days!!!

~Jessica
 

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