我有一个监测员工休假和培训的数据库,每8周一个小组将收集并进行培训,我想要的是一种方法,而不是单独分配给每个成员一个培训活动id,而不是打开该活动并选择参与者,从这里到目前为止,每个工作人员都会对他们进行这种特定的培训--我让每个工作人员都被ID和GID认可,但是在针对所有ID的情况下进入这个培训活动有困难吗?
发布于 2015-01-30 12:40:12
这个大容量插入很可能是通过使用未绑定表单来完成的。最小的控件是一个Listbox、ComboBox、一个TextBox和一个Button。
ListBox (staffList),应该允许它选择多个项;它将从Staff表中获取其RowSource,类似于
SELECT
staffID,
staffName
FROM
staffTable;属性是Bound Column : 1,Column Count : 2,Column Widths : 0cm;2.542cm
ComboBox (eventCombo)将从事件表中获取其RowSource,如下所示
SELECT
eventID,
eventName
FROM
eventTable;属性是Bound Column : 1,Column Count : 2,Column Widths : 0cm;2.542cm
然后,TextBox (dateTxt)将只有一个日期控件(用于事件的日期)。
按钮(addEventBtn)点击后的代码很简单,
Private Sub addEventBtn_Click()
Dim varItem As Variant
If Me.staffList.ListIndex = -1 Then
MsgBox "No Staff selected. You have to select at least one staff before you can proceed !", vbCritical
Me.dateTxt.SetFocus
Exit Sub
End If
If Me.eventCombo.ListIndex = -1 Then
MsgBox "No Event selected. You have to select at least one staff before you can proceed !", vbCritical
Me.dateTxt.SetFocus
Exit Sub
End If
If IsNull(Me.dateTxt) Then
MsgBox "No Date selected. You have to select Date before you can proceed !", vbCritical
Me.dateTxt.SetFocus
Exit Sub
End If
For Each varItem In Me.staffList.ItemsSelected
CurrentDB.Execute "INSERT INTO tbl_EventList (eventID_FK, staffID_FK, eventDate) VALUES (" & _
Me.eventCombo & ", " & Me.staffList.ItemData(varItem) & ", " & Format(Me.dateTxt, "\#mm\/dd\/yyyy\#") & ")"
Next
End Sub这应该可以解决。请根据您的设计更改它!如果您有任何问题,请添加到评论。
https://stackoverflow.com/questions/28227756
复制相似问题