MajP
You've got your good things, and you've got mine.
- Local time
- Today, 13:02
- Joined
- May 21, 2018
- Messages
- 8,533
This works pretty well. I will post the demo later.
1) Build a small pop up form with a listbox and two command buttons. One with an up arrow and one with a down arrow. This will allow you to move the items in the listbox up and down. My listbox is called lstSort. MyForm is Called FrmSortForms
2) On each of your forms put some way to to open the pop up. I put a command button in upper left, but you could do a custom menu
3) Here is the code for the pop up. I recycled from something I had except for the hide and show forms.
It is easy enough user interface to use and looks like you are "sorting" the tabs.
1) Build a small pop up form with a listbox and two command buttons. One with an up arrow and one with a down arrow. This will allow you to move the items in the listbox up and down. My listbox is called lstSort. MyForm is Called FrmSortForms
2) On each of your forms put some way to to open the pop up. I put a command button in upper left, but you could do a custom menu
Code:
Private Sub cmdSort_Click()
DoCmd.OpenForm "frmSortForms"
End Sub
Code:
'--------------------------------------------------- List Box Code to Move Items
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
HideShow Me.lstSort
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
HideShow Me.lstSort
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
lst.Selected(ind) = True
End Sub
'-------------------------------------------------- Form Code to Load Listbox
Private Sub Form_Load()
Dim frm As Access.Form
With Me.lstSort
.AllowValueListEdits = False
.ColumnCount = 1
.RowSourceType = "value list"
End With
For Each frm In Forms
If frm.Name <> Me.Name Then
addItem Me.lstSort.ListCount, frm.Name, Me.lstSort
End If
Next frm
If Me.lstSort.ListCount >= 0 Then Me.lstSort.Selected(0) = True
End Sub
'---------------------------------------------------- Code for Tab Forms
Public Sub HideForms()
Dim frm As Access.Form
For Each frm In Forms
If frm.Name <> Me.Name Then
frm.Visible = False
End If
Next frm
End Sub
Public Sub ShowTabs(lst As Access.ListBox)
Dim i As Integer
Dim frmName As String
For i = 0 To lst.ListCount - 1
frmName = lst.ItemData(i)
Forms(frmName).Visible = True
Next i
Forms(lst.ItemData(0)).SetFocus
End Sub
Public Sub HideShow(lst As Access.ListBox)
HideForms
ShowTabs lst
End Sub
It is easy enough user interface to use and looks like you are "sorting" the tabs.