Connecting Tech Pros Worldwide Forums | Help | Site Map

Cascading Combo/List Boxes help

Member
 
Join Date: Jul 2007
Posts: 53
#1: Jul 31 '07
Hi,

I've been through the tutorial for this and I've tried applying it to my database and it almost works but not quite.

i have 2 combo boxes, cboPrgrp and cboSupplier. cboPrgrp is supposed to populate once a selection is made for cboSupplier. When a selection is made in cboSupplier and I click the dropdown box for cboPrgrp, it will prompt me saying whatever the selection is in cboSupplier. If I type in what was selected in cboSupplier, then cboPrgrp will populate properly. My question is why is it prompting me?

Here is the code to populate cboPrgrp:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSupplier_AfterUpdate()
  2. With Me![cboPrgrp]
  3. .RowSource = " "
  4. .RowSource = "SELECT DISTINCT [COMCOD] " & _
  5.                      "FROM dbo_ICI1 " & _
  6.                      "WHERE [SUPPLR] =" & Me!cboSupplier
  7. .Requery
  8. End With
  9. End Sub
  10.  
Note that [COMCOD] is what goes in cboPrgrp.

Anybody know why it's prompting me?

JKing's Avatar
Moderator
 
Join Date: Jun 2007
Location: Niagara Falls, Ontario
Posts: 557
#2: Jul 31 '07

re: Cascading Combo/List Boxes help


Is the prompt specifying anything or are you just seeing "Enter Parameter Value"? This error is usually caused by typos as Access cannot determine which variable /control/field you are referring to.
Member
 
Join Date: Jul 2007
Posts: 53
#3: Jul 31 '07

re: Cascading Combo/List Boxes help


Quote:

Originally Posted by JKing

Is the prompt specifying anything or are you just seeing "Enter Parameter Value"? This error is usually caused by typos as Access cannot determine which variable /control/field you are referring to.

It says "Enter Paramater Value" in the caption of the box (the top bar of the box). Then it says whatever the selection is in cboSupplier and then it has a box for me to type something in. So if my selection in cboSupplier is "EPPUSA" It looks like this:

Enter Parameter Value|X|

EPPUSA____________________
||_________________________|

This is what I'm seeing.
JKing's Avatar
Moderator
 
Join Date: Jun 2007
Location: Niagara Falls, Ontario
Posts: 557
#4: Jul 31 '07

re: Cascading Combo/List Boxes help


Hehe I liked the visual, thank you. I think I know the problem.
Give this a try:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSupplier_AfterUpdate()
  2. With Me![cboPrgrp]
  3. .RowSource = " "
  4. .RowSource = "SELECT DISTINCT [COMCOD] " & _
  5.                      "FROM dbo_ICI1 " & _
  6.                      "WHERE [SUPPLR] = '" & Me!cboSupplier &"'"
  7. .Requery
  8. End With
  9. End Sub
  10.  
Supplier is of the text data type. So you need to enclose it with the single quotes. I believe without them access assumes the value of your combo box to be an unknown variable.
Member
 
Join Date: Jul 2007
Posts: 53
#5: Jul 31 '07

re: Cascading Combo/List Boxes help


Quote:

Originally Posted by JKing

Hehe I liked the visual, thank you. I think I know the problem.
Give this a try:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSupplier_AfterUpdate()
  2. With Me![cboPrgrp]
  3. .RowSource = " "
  4. .RowSource = "SELECT DISTINCT [COMCOD] " & _
  5.                      "FROM dbo_ICI1 " & _
  6.                      "WHERE [SUPPLR] = '" & Me!cboSupplier &"'"
  7. .Requery
  8. End With
  9. End Sub
  10.  
Supplier is of the text data type. So you need to enclose it with the single quotes. I believe without them access assumes the value of your combo box to be an unknown variable.

It works beautifully now, thanks bud :) .
JKing's Avatar
Moderator
 
Join Date: Jun 2007
Location: Niagara Falls, Ontario
Posts: 557
#6: Jul 31 '07

re: Cascading Combo/List Boxes help


No problem glad I could help.
Reply