473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Combo Box List

I used the data form and data adapter wizards to build a data entry form.
However, rather than using text boxes for all of the fields, I would like to
use dropdown lists for some of the fields. What's the best way to populate
the selection list from a lookup table in my database.

Bob
Nov 21 '05 #1
1 1127
Hi Robert,
I've something very similar to what you described here. So this is my
method:
1. Build your DataForm using the data form wizard as usual
2. Once it's done and working (make sure that it works because the dataforms
created using data form wizard not always work 100%), then add a ListBox (I
used a comboBox) to the DataForm for each of the text fields you want to
replace. Put the ListBox on top of the TextBox to hide it.
3. In your code, do this:
a. In the Sub LoadDataSet(), add this code

Public Sub LoadDataSet()
'Create a new dataset to hold the records returned from the call to
FillDataSet.
'A temporary dataset is used because filling the existing dataset
would
'require the databindings to be rebound.
Dim objDataSetTemp As Testing.myDs
objDataSetTemp = New Testing.myDs
Try
'Attempt to fill the temporary dataset.
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
'Add your error handling code here.
Throw eFillDataSet
End Try
Try
'Empty the old records from the dataset.
objmyDs.Clear()
'Merge the records into the main dataset.
objmyDs.Merge(objDataSetTemp)
'
'Add this code.............. Replace the table name "Users" & the column
name "uDomain" to match your dataset
'
'Creates a copy of the dataset to load ComboBox1
Dim ds As DataSet = New DataSet
Dim i As Integer
ds = objmyDs
For i = 0 To ds.Tables("Users").Rows.Count - 1
ComboBox1.Items.Add(ds.Tables("Users").Rows(i).Ite m("uDomain"))
Next
'Done with dataset... Get rid of it
ds.Dispose()
ds = Nothing
'
'End of adding....................................
Catch eLoadMerge As System.Exception
'Add your error handling code here.
Throw eLoadMerge
End Try

End Sub

b. If you want the Items in ComboBox1 to change when you move between
records, add this code to your dataset_PositionChange() Sub.

Private Sub objmyDs_PositionChanged()
Me.lblNavLocation.Text = (((Me.BindingContext(objmyDs,
"Users").Position + 1).ToString + " of ") _
+ Me.BindingContext(objmyDs, "Users").Count.ToString)
'
'Add this code here *****************************
'
ComboBox1.SelectedItem =
ComboBox1.Items.Item(Me.BindingContext(objmyDs, "Users").Position)
ComboBox1.Refresh()
'
'*******************************************
End Sub

Hope this helps.
Stanav.

"Robert Boudra" <rb*****@comcast.net> wrote in message
news:uh****************@TK2MSFTNGP09.phx.gbl...
I used the data form and data adapter wizards to build a data entry form.
However, rather than using text boxes for all of the fields, I would like
to use dropdown lists for some of the fields. What's the best way to
populate the selection list from a lookup table in my database.

Bob

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mal | last post by:
Sorry for repost - system added to another subject for some reason Have tried numerous ideas from the group to solve this one. It is such a simple example that it should be straightforward ! I...
2
by: Robert | last post by:
Am using a nested continuous bound subform to add multiple records to the underlying table. One of the fields is based on a limit to list combo box. Any suggestions on best way to progressively...
2
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to...
8
by: AA Arens | last post by:
Hi I do have a products table and products-parts table in my Access 2003 database and log all services into a form. I do have at least the following two combo boxes on my form: - Choose...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
0
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.