Multi Select to assign materials issue

komo

Registered User.
Local time
Today, 05:25
Joined
Jul 27, 2016
Messages
25
Hello Everyone,

Hope you can help me with this, seeing that my experience with coding is not that great.

What I am trying to do:
I currently have a form where I can assign "tasks" to various "employees" (multi select) with the assigned date. The code kind of works, however instead of listing the each employee to it's individual record, it's in a list.

What table [tblTaskSched] shows:
[ID]................[Tasks].........[EmployeeID]............[DateAssigned]
Auto................Task1..............12, 43, 65, 88.............8/26/16

How it needs to be displayed:
[ID]................[Tasks].........[EmployeeID]............[DateAssigned]
Auto................Task1.............. 12 .............8/26/16
Auto................Task1.............. 43 .............8/26/16
Auto................Task1.............. 65 .............8/26/16
Auto................Task1.............. 88 .............8/26/16

Tables:
tblTaskSched
ID (auto)
Name (short-didn't link to tblTask.Task on tbl end but did link it in the form)
EmployeeID (short- same as above)
DateAssigned
tblTask
ID
Name (hyperlink due to it being link to a file this is being linked to tblTaskSched in the form as well)
TaskName (short version of Task without hyperlink)
TaskCode
tblEmployee
EmployeeID (short)
Name
FName
LName


Code (which is EventProcedure for a button on same form):

'Purpose: This forms allows users to assign the specific Tasks to Employees for them to view
Option Compare Database
Option Explicit
___________________________________
Private Sub cmdAssign_Click()
On Error GoTo Err_cmdAssign_Click
Dim MyDB As dao.Database
Dim varItem As Variant
Dim lst As ListBox
Set lst = Me![EmployeeID]
Dim rst As dao.Recordset
If lst.ItemsSelected.Count = 0 Or IsNull(Me![cboTaskName]) Or IsNull(Me![txtDateAssigned]) Then
MsgBox "Please verify that there is a Task Name and that you've assigned Employee(s) in order to proceed.", vbExclamation, _
"Missing Data Input"
Exit Sub
End If
Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset("tblTaskSched", dbOpenDynaset, dbAppendOnly)
With rst
For Each varItem In lst.ItemsSelected
.AddNew
![Name] = Me![cboTaskName]
![EmployeeID] = lst.ItemData(varItem)
![DateAssigned] = Me![txtDateAssigned]
.Update
Next varItem
End With
rst.Close
Set rst = Nothing
DoCmd.OpenTable "tblTaskSched", acViewNormal, acReadOnly
DoCmd.Maximize
Exit_cmdAssign_Click:
Exit Sub
Err_cmdAssign_Click:
MsgBox Err.Description, vbExclamation, "Error in cmdAssign_Click()"
Resume Exit_cmdAssign_Click
End Sub



error I'm receiving when I try to click on the "Assign" button in Form View:
Method 'Collect' of object 'RecordSet2' failed.


other note:
Not sure if this is affecting it but in the form when I multi select the "Employee" to assign, the listbox is showing the check mark on the side.

should it be a listbox that has the ctrl+select option?

Or doesn't matter? If it does, what should I do?


In addition when I go back to the form to Assign another "task", it uses the same record and changes the values instead of adding a new one....
 
Last edited:
are you talking about a multi-select listbox or a listbox with a multi-value field?
i suspect it is an MVF.
 
are you talking about a multi-select listbox or a listbox with a multi-value field?
i suspect it is an MVF.

I believe it's currently MVF that is the issue? I don't want each task to have multiple employees in a record/line (which I thought I clarified? in original post)
 
Last edited:
Avoid:
-multivalued fields
-lookup at table field level
-names with embedded spaces or special characters (stick with alpha and the "_"--to make Access happy)
-reserved words (see these from Allen Browne)

In simple English (no jargon, no database-ese) give us the 30,000 ft overview of what you are trying to do. Do not start with I have a form--that's part of your proposed solution --a HOW if you will. We need to know WHAT so we have understanding of your issue to be solved/addressed/automated.

I see employee, task. I don't see project, task type, customer --of course these may not apply and/or may not be in scope.

Good luck with your project.
 
I believe it's currently MVF that is the issue?
yes its probably part of it. i didnt study your code but the fact that you have checkboxes in a combo points to an MVF.
 
Thanks for the help it was the MVF that I accidently set up in the beginning.
 

Users who are viewing this thread

Back
Top Bottom