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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another combobox question

Status
Not open for further replies.

ZX188

Technical User
Mar 30, 2001
21
US
I have a combobox with the row source creating a select query I need the querys criteria to be set by what is in another field on this form (BillTo) I tried something like this
SELECT worksheet.[PO#], worksheet.OurPartNumber, worksheet.Description, worksheet.CustomerID FROM worksheet WHERE (((worksheet.CustomerID)=Me.[BillTo]));
But it didn't work
 
Hi,

In the BillTo field's afterupdate event you should have:
cboName.requery

cboname is the name of your combobox with the select query as a rowsource.

Have a good one!
BK
 
Didn't seem to do anything
do I leave my rowsource in the combobox the same?
 
Hi,

Let me try to understand what you want to do, you have a textbox named BillTo? You want to display some values in a combobox using the value in BillTo as criteria? Yes, there is no need to change the rowsource of your combobox.

Is your textbox that represents the BillTio field called BillTo? You have to use the name of the textbox in your query like Me.BillTo (no braces). When you say it doesn't work what exactly happens? I assume that BillTo is a bound textbox to CustomerID?

Have a good one!
BK
 
I get no choices in my other combobox
You got it all correct except that the BillTo is also a combobox
 
I also tryed it this way
SELECT worksheet.[PO#], worksheet.OurPartNumber, worksheet.Description, worksheet.CustomerID FROM worksheet WHERE (((worksheet.CustomerID)=[Forms]![Orders]![BillTo]));
 
Did you actually click on the combo box to drop down the list? I remember when I first did this procedure, I saw nothing in the combo box. After trying different code changes, I finally clicked on the combo box arrow and saw the data was actually there. Terry
 
Re your most recent posting, agree with Terry that the data should be there.

In the AfterUpdate event of BillTo, try adding the following:

With Me!CboName
.Requery
.SetFocus
.Dropdown
End With



The other way to do this is to push the data to cboName when BillTo is updated. To accomplish this, you would add the following to the BillTo AfterUpdate event:

Dim strSQL As String

strSQL = "SELECT worksheet.[PO#], worksheet.OurPartNumber, " _
& "worksheet.Description, worksheet.CustomerID FROM worksheet " _
& "WHERE CustomerID = " & Me![BillTo] & ";"

With Me!cboName
.RowSource = strSQL
.SetFocus
.Dropdown
End With
 
I Figured out what I was doing wrong the first combo box was bound to the wrong field

Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top