Gizem
Member
- Local time
- Today, 01:11
- Joined
- Nov 29, 2021
- Messages
- 30
Hello together,
i need help again A couple of weeks ago, i got so many advices.
I have two listboxes. The first one is filled with data and the other one is empty. Now the User wants to fill the second Listbox by using the first Listbox and a button. The User has to choose one element in the first Listbox with a click on it. The data origin is a table. The table has three colomns(ID, POSITION, NAME).
I get a runtime error 3134: Syntax Error in INSERT-INTO Statement.
I hope you can see my failure
i need help again A couple of weeks ago, i got so many advices.
I have two listboxes. The first one is filled with data and the other one is empty. Now the User wants to fill the second Listbox by using the first Listbox and a button. The User has to choose one element in the first Listbox with a click on it. The data origin is a table. The table has three colomns(ID, POSITION, NAME).
Code:
Private Sub HinHer(Ctl0 As Control, Ctl1 As Control, OnlySelected As Boolean)
Dim Itm, Wert, Tbl1, Tbl0, DB As Database
Set DB = CurrentDb
Tbl0 = Ctl0.RowSource
Tbl1 = Ctl1.RowSource
If Ctl1.ListCount = 0 Then
For Itm = 0 To Ctl0.ListCount - 1
If Not OnlySelected Or Ctl0.Selected(Itm) Then
Wert = Ctl0.ItemData(Itm)
DB.Execute "INSERT INTO " & Tbl1 & "(NAME) VALUES ('" & Wert & "')"
End If
Next Itm
End If
If Ctl1.ListCount > 0 Then
Dim var0 As Integer
Dim var1 As Integer
Dim var2 As Integer
var0 = Ctl1.ListCount
For Itm = 0 To Ctl0.ListCount - 1
If Not OnlySelected Or Ctl0.Selected(Itm) Then
For var1 = 0 To var0 - 1
Wert = Ctl0.ItemData(Itm)
If Me.Liste37.ItemData(var1) = Wert Then
MsgBox "Sie haben das schon eingefügt ?!"
Exit Sub
End If
Next var1
DB.Execute "INSERT INTO " & Tbl1 & "(PS_P_NAME) VALUES ('" & Wert & "')"
End If
Next Itm
End If
Ctl0.Requery
Ctl1.Requery
Set DB = Nothing
End Sub
I get a runtime error 3134: Syntax Error in INSERT-INTO Statement.
I hope you can see my failure