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

Filling a combo box with data

Status
Not open for further replies.

GaryWilsonCPA

Technical User
Joined
Jul 19, 2000
Messages
253
Location
US
I have used a combo box on a form generated by the dataform wizard. It will draw the data from the table configured with the form.

I want to draw data from a different table that I added to the form. I added a oleadapter and a dataset. The combo box doesnt fill up with data.

This is the code I am trying....

Public Sub filldataset(ByVal dataset As DublinFundRaisingProject.DatasetContacts)
Me.OleDbConnection1.Open()
dataset.EnforceConstraints = False
Try
Me.DSContacts.Fill(dataset)

Catch fillexception As System.Exception
Throw fillexception
Finally
dataset.EnforceConstraints = True
Me.OleDbConnection1.Close()

End Try


My combo box doesnt populate when i run the code..Doesanyone have ideas?








 
change the datasource property of the dropdown to the new DataSet

-
"Do your duty in all things. You cannot do more, you should never wish to do less." Robert E. Lee
 
I am still stumped on this. My combo box has no data showing up.

Should i have additional code besides what is above?

I am using access data with an oledb adapter.

 
You need to set the datasource and or datamember of the combobox equal to the dataset and table you're trying to pull from.

Sort of like this.



Public Sub filldataset(ByVal dataset As DublinFundRaisingProject.DatasetContacts)
Me.OleDbConnection1.Open()
dataset.EnforceConstraints = False
Try
Me.DSContacts.Fill(dataset)


ListBox1.DataSource = DataSet1.Tables("tblItem")
ListBox1.DisplayMember = "Item_Name"



Catch fillexception As System.Exception
Throw fillexception
Finally
dataset.EnforceConstraints = True
Me.OleDbConnection1.Close()

End Try
 
Thanks for your help. I got it to work....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top