Sub ListBoxExample(DragFrm As Form, DragCtrl As Control, DropFrm As Form, DropCtrl As Control, _
Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim DB As DATABASE
Dim SQL As String
Set DB = CurrentDb()
' Create SQL statement to update Selected field of
' .. drag/dropped list box item.
SQL = "UPDATE tbl_Master_Baseline_Event SET Selected ="
' Drag from List1 toggle Selected=True, List2 toggles False.
SQL = IIf(DragCtrl.Name = "List1", SQL & "True", SQL & "False")
' If CTRL key not used, alter dragged value only.
If (Shift And CTRL_MASK) = 0 Then
SQL = SQL & " WHERE [Reported_EventID]='" & DragCtrl & "'"
End If
' Run update query to toggle Selected field of Customer record(s).
DB.Execute SQL
' Requery the list box controls to show update lists.
DragCtrl.Requery
DropCtrl.Requery
End Sub
|