Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub Form_Load()
Dim lst As Access.ListBox
Dim str As String
Dim rs As DAO.Recordset
Set lst = Me.lstSort
Set rs = CurrentDb.OpenRecordset("Products")
Do While Not rs.EOF
str = str & rs!productid & ";" & rs!productname & ";"
rs.MoveNext
Loop
lst.RowSource = str
End Sub
Private Sub cmdDown_Click()
Call moveDown(Me.lstSort)
End Sub
Private Sub cmdup_Click()
Call moveUp(Me.lstSort)
End Sub
Public Sub moveUp(lst As Access.ListBox)
Dim ind As Long
Dim val As String
Dim col As Integer
ind = lst.ListIndex
If Not ind <= 0 Then
For col = 0 To lst.ColumnCount - 1
val = val & lst.Column(col, ind) & ";"
Next col
Call delItem(ind, lst)
Call addItem(ind - 1, val, lst)
End If
End Sub
Public Sub moveDown(lst As Access.ListBox)
Dim ind As Long
Dim val As String
Dim col As Integer
ind = lst.ListIndex
If Not (ind = lst.ListCount - 1 Or ind < 0) Then
For col = 0 To lst.ColumnCount - 1
val = val & lst.Column(col, ind) & ";"
Next col
Call delItem(ind, lst)
Call addItem(ind + 1, val, lst)
End If
End Sub
Public Sub delItem(ind As Long, lst As Access.ListBox)
lst.RemoveItem ind
End Sub
Public Sub addItem(ind As Long, val As String, lst As Access.ListBox)
lst.addItem val, ind
End Sub