Question : Access 2003 Drag and Drop

Hi experts,

I'm trying to understand this code which I downloaded for a simple drag and drop.  I have a form setup and working with two list boxes.

It falls over when at the DB.Execute SQL statement, I think because my Reported_EventID field is a numeric field not a text field as per the demonstration software.

I assume the  SQL = SQL & " WHERE [Reported_EventID]='" & DragCtrl & "'"
is the error but for the life of me I dont understand how to change it to reflect a numeric field rather than text.

thanks in advance.
Red
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
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

Answer : Access 2003 Drag and Drop

Compare the following Where conditions:For numeric:
"Where x = " & var
For string:
"Where x = '" & var & "'"

Note the use of  ' , ", and  &  
Random Solutions  
 
programming4us programming4us