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

Populating A List Box From A Table In Access97

Status
Not open for further replies.

zp162002

Programmer
Feb 3, 2003
39
US
Can anyone please give me a quick example of how I would go about populating a list box on a form using data from a table with two fields - SellerID and OtherID? I want to look for every record that contains a particular SellerID (this will be on an underlying form) and to have all the associated OtherID values placed in a list box so the user can delete them if necessary. Hope this made sense. Any help that you can provide will be greatly appreciated.

PZ
 
In the AfterUpdate event of the txtSellerID control, set the RowSource property of the combo like this:
theCombo.RowSource = "SELECT SellerID,OtherID FROM theTable WHERE SellerID='" & txtSellerID & "';"
theCombo.Requery
If SellerID is defined as numeric, get rid of the single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

I tried your suggestion but the list box is not populated with the appropriate OtherIDs. The code should run when I enter the list box lstOtherID. It opens up a form - frmAddID. Please see below and let me know what you think.

Private Sub Form_Open(Cancel As Integer)
Me.lstCurrentID.RowSource = "Select SellerNameID, OtherID, FROM tblOtherID WHERE SellerNameID = '" & Forms!frmSellerEdit!txtSellerNameID & "';"
lstCurrentID.Requery
End Sub

The SellerID value is from an underlying form - frmSellerEdit. The field name is - SellerNameID.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top