here is also a demo but the listbox rowsource is Table/query.
I tried this one because it is quite similar to my problem. I add a third colomn to my table like the demo and named it also POSITION. I got a run-time-error 13 'Type mismatch'. Also i have changed the declaration to variant. But now i got an other run-time error maybe you can find the failure.
Private Sub MoveUpDown(value As Integer)
Dim newpos As Variant
Dim oldpos As Variant
Dim ok As Boolean
Dim index As Long
If Me.Liste13.ListIndex = -1 Then
'do nothing nothing is selected
Else
If value = -1 Then 'move up
If Me.Liste13.ListIndex <> 0 Then
index = Me.Liste13.ListIndex - 1
oldpos = Me.Liste13.Column(0, Me.Liste13.ListIndex)
newpos = Me.Liste13.Column(0, index)
ok = True
End If
Else 'move down
If Me.Liste13.ListIndex <> Me.Liste13.ListCount - 1 Then
index = Me.Liste13.ListIndex + 1
oldpos = Me.Liste13.Column(0, Me.Liste13.ListIndex)
newpos = Me.Liste13.Column(0, index)
ok = True
End If
End If
If ok Then
DBEngine(0)(0).Execute "update ProjekteName set position=9999 " & _
"where position = " & newpos & ";"
DBEngine(0)(0).Execute "UPDATE ProjekteName set position= " & newpos & " " & _
"where position = " & oldpos & ";"
DBEngine(0)(0).Execute "UPDATE ProjekteName set position= " & oldpos & " " & _
"where position = 9999" & ";"
Me.Liste13.Requery
Me.Liste13 = Me.Liste13.ItemData(index)
End If
End If
End Sub
DBEngine(0)(0).Execute "update ProjekteName set position=9999 " & _
"where position = " & newpos & ";"
Run-time-error '3075'
Syntax error(missing operator) in query expression 'position=...'
I can't find the failure it is so annoying