473,396 Members | 2,010 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,396 software developers and data experts.

Loading a Combo Box with Employee Names

I am developing a Payroll Program. I have created a Database Table in Ms Access 2000. I have placed Text Box controls on my Vb 6 Form including a Combo box.
I want to fill the combo box with employee names when the Form loads. I have tried to write codes that will do this, but can't get it done.

Please kindly assist me. What is wrong with the following codes?:
Private Sub Form_Load()
With adoSubjects.Recordset
Do Until Not .EOF
If !SubjectCode <> "" Then
cboSubjects.AddItem !SubjectCode
End If
.MoveNext
Loop
.Close
End With

Thanks.
Akinyemi.
Feb 19 '07 #1
2 1503
dorinbogdan
839 Expert 512MB
What kind of error/problem do you get?
Feb 19 '07 #2
Hi,

am developing a Payroll Program. I have created a Database Table in Ms Access 2000. I have placed Text Box controls on my Vb 6 Form including a Combo box.
I want to fill the combo box with employee names when the Form loads. I have tried to write codes that will do this, but can't get it done.

Please kindly assist me. What is wrong with the following codes?:
Private Sub Form_Load()
With adoSubjects.Recordset
Do Until Not .EOF
If !SubjectCode <> "" Then
cboSubjects.AddItem !SubjectCode
End If
.MoveNext
Loop
.Close
End With

Thanks.
Akinyemi.
Would it not be simpler to set you combo box source to a table/query type then set the rowsource to the SQl string, followed by a requery,

The following code works for me;

Private Sub Frame38_Click()

Dim a As Variant:

a = Me.Frame38.Value

Select Case a

Case 1
strSQL = "SELECT Cat.Index, Cat.Category FROM Cat;"
Case 2
strSQL = "SELECT [Position].[Index], [Position].[Position] FROM [Position]; "
End Select


Me.List43.RowSource = ""
Me.List43.RowSource = strSQL
Me.List43.Requery

End Sub

Though this is used in frame, the priciple is the same, as a button is selected the rowsource of the unbound list bow is removed, changed, the refreshed to show the changes.

This allows you to change the contents of the list box/combo box on the fly, depending on the status of the buttons, The only thing to remember is to include the index of your table (should be numerical), and the format of you list box/combo box you can elect to either show or hide the index number. This can be done as an onload feature, thus giving up to date list in the combo box. I just use the option box selected number and the number of the combo box when refering to an item later on.

Hope this helps, or maybe I've just got the wrong end of your stick.....

Alan Hill
Feb 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Salad | last post by:
On you form you have a combo box of a list of employees. In the Employee table you have the employee name, employee id, and an ActiveInactive status. Initially, the list contains the names of...
0
by: JL3574 l | last post by:
i have a datagrid with a combo box added in it's columns . the combobox pulls values from a database in it's dropdownlist fashion. my problem is that when i pick a select on the combo box it...
17
by: Aussie Rules | last post by:
Hi, I want to have a single line combo box dropdown, but where i can selected multiple items in the drop down via a check box... I can see one in the standard tool box... is there one ? If...
4
by: Elena | last post by:
Hi, I am filling in a combobox. I would like to concatenate two fields into the data combo box and display "last name, first name" I tried to displaymember = "employee_last_name" & ", " &...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
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...
11
by: martin DH | last post by:
I have an Access database of employees. Each employee has a unique identification number called "BANNER_ID". Each employee's last name and first name are in the database but are not unique...
3
by: tbrogdon | last post by:
I have a form (myForm) which has the following combo boxes: 1) Shift (selects shift 1, 2, or 3 from tblShift) this value is not stored in a field. 2) Department (selects Dept1, Dept2, or Dept3...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.