473,568 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading a Combo Box with Employee Names

32 New Member
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.Rec ordset
Do Until Not .EOF
If !SubjectCode <> "" Then
cboSubjects.Add Item !SubjectCode
End If
.MoveNext
Loop
.Close
End With

Thanks.
Akinyemi.
Feb 19 '07 #1
2 1506
dorinbogdan
839 Recognized Expert Contributor
What kind of error/problem do you get?
Feb 19 '07 #2
AlanHill1965
8 New Member
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.Rec ordset
Do Until Not .EOF
If !SubjectCode <> "" Then
cboSubjects.Add Item !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.Valu e

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.RowSo urce = ""
Me.List43.RowSo urce = strSQL
Me.List43.Reque ry

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
1627
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 all employees and may be a small list. As time goes on some move on, new employees are added and the list grows longer. Well, we could trim the...
0
1607
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 doesn't stay on the cell after selected almost as if the combobox is on top of the cell and after u select an item and click next cell or column the...
17
14791
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 not any suggestions as to where to get one from.
4
11785
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" & ", " & "employee_last_name", but it did not like that. I can fill the combo box with either the first or the last, but I cannot manage to concatenate it.
8
8240
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 company and has been flagged inactive. If you have a filter on the rowsource like Where Active = True then Joe's name would not show up in the combo...
4
64549
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 determines the available options in the other. TERMINOLOGY Row Source: The table/query from which the Combo Box or List Box gets its values. Note:...
11
2669
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 (obviously). The data is stored in a table named EMPLOYEE. I want to create a search option whereby managers can search for an employee by "BANNER_ID" by...
3
1416
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 from tblDept) this value is also not stored. 3) Then I have a combo box for Employees' names. This list is generated from tblEmployees w/ fields...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.