Fill a combo box based on another

G

Guest

I've been trying to fill a combo box after another is being updated, but I
have been doing it unsuccessfully. I only have one table that includes two
fields named Item and Barcode. I have a form with two combo boxes with
rowsources coming from those two fields. That works fine, but when I select
something in one combo box, I can't get the other combo box to update from
that.
This is how I tried doing it:

Private Sub ItemName_AfterUpdate()

If Len(ItemName) > 0 Then
With Barcode
.RowSource = _
"SELECT Barcode " & _
"FROM Original WHERE Item = " & ItemName
.Requery
.SetFocus
.Dropdown
End With
End If

End Sub

ItemName and Barcode are my combo boxes names.

Chris
 
J

JethroUK©

how about binding one combo to both fields

combo.RowSource = "SELECT DISTINCT itemname, barcode FROM mytable ORDER BY
itemname ASC; "

note: you need to set combo to display both columns
 
M

Marcin

U¿ytkownik "Chris said:
I've been trying to fill a combo box after another is being updated, but I
have been doing it unsuccessfully. I only have one table that includes two
fields named Item and Barcode. I have a form with two combo boxes with
rowsources coming from those two fields. That works fine, but when I select
something in one combo box, I can't get the other combo box to update from
that.
This is how I tried doing it:

Private Sub ItemName_AfterUpdate()

If Len(ItemName) > 0 Then
With Barcode
.RowSource = _
"SELECT Barcode " & _
"FROM Original WHERE Item = " & ItemName
.Requery
.SetFocus
.Dropdown
End With
End If

End Sub

ItemName and Barcode are my combo boxes names.

Chris

============================================================================
================
FULL LEGAL SOFTWARE !!!
Games, video, program, image, chat, questbook, catalog site, arts, news,
and...
This site it is full register and legal software !!!
Please download and you must register software !!!

PLEASE REGISTER SOFTWARE:
http://www.webteam.gsi.pl/rejestracja.htm
DOWNLOAD LEGAL SOFTWARE:
http://www.webteam.gsi.pl

Full question and post: http://www.webteam.gsi.pl

Contact and service and advanced technology:
http://www.webteam.gsi.pl/kontakt.htm
FAQ: http://www.webteam.gsi.pl/naj_czesciej_zadawane_pytania.htm

Please add me URL for you all site and search engines and best friends !!!

Me site:
SERWIS WEBNETI: http://www.webneti.gsi.pl
PORTAL WEBTEAM: http://www.webteam.gsi.pl
LANGUAGE: http://www.webneti.cjb.net
============================================================================
================
 

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