accvbalearner
Registered User.
- Local time
- , 18:18
- Joined
- Jan 3, 2013
- Messages
- 42
Hello All,
I need some help and I'm sure there is a someone out there who know exactly how to solve my issue!
I have an Access form, in the form the user enters or picks a date, chooses a project from a combobox and then a report from a combobox. The first two boxes (date and project) filter the third box. There are also two multiselect listboxes as well WO and Emp. When the user chooses a project number the WO listbox filters for the work orders for that job. At the same time the Emp listbox filters for the employees that worked that day on that project.
The Emp listbox is also a multicolumn listbox. What i'd like to have happen is for the user to select the date, project and report then click each person that is listed as working on a the report for the day. Once the user has finished selecting then they can click a button and add the selection to a table.
I have it working with the work orders, but with the Emp I can only get it to add the data from the first column. After that it just repeats the data from the last row selected into the columns of the table.
Basically, I need to know how to tell the form to grab the data from columns in the rows that were selected, not just the data in the columns from the last row selected.
Below is my code:
Thanks in advance for any help or ideas you can provide!
Take Care,
accvbalearner
I need some help and I'm sure there is a someone out there who know exactly how to solve my issue!
I have an Access form, in the form the user enters or picks a date, chooses a project from a combobox and then a report from a combobox. The first two boxes (date and project) filter the third box. There are also two multiselect listboxes as well WO and Emp. When the user chooses a project number the WO listbox filters for the work orders for that job. At the same time the Emp listbox filters for the employees that worked that day on that project.
The Emp listbox is also a multicolumn listbox. What i'd like to have happen is for the user to select the date, project and report then click each person that is listed as working on a the report for the day. Once the user has finished selecting then they can click a button and add the selection to a table.
I have it working with the work orders, but with the Emp I can only get it to add the data from the first column. After that it just repeats the data from the last row selected into the columns of the table.
Basically, I need to know how to tell the form to grab the data from columns in the rows that were selected, not just the data in the columns from the last row selected.
Below is my code:
Code:
Private Sub btn_AddEmployees_Click()
' This button will add selected Employees to a table
' alongwith the selected Job Number and Report Number.
Dim db As Database
Dim rs As Recordset
Dim strsel_JNbr As String
Dim strsel_RNbr As String
Dim var_Emp As Variant
Set db = CurrentDb()
Set rs = db.OpenRecordset("RNEmp", dbOpenDynaset, dbSeeChanges)
strsel_JNbr = Inclsel_JNbr()
strsel_RNbr = Inclsel_RNbr()
For Each var_Emp In sel_Emp.ItemsSelected()
rs.AddNew
rs!EmpName = sel_Emp.ItemData(varItem)
'rs!EmpClass = sel_Emp.Column(1, varItem)
'rs!Badge = sel_Emp.Column(2, varItem)
'rs!MicroEID = sel_Emp.Column(3, varItem)
rs!JobNbr = strsel_JNbr
rs!RepNbr = strsel_RNbr
rs.Update
Next
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Thanks in advance for any help or ideas you can provide!
Take Care,
accvbalearner