Mike Krailo
Well-known member
- Local time
- Yesterday, 19:01
- Joined
- Mar 28, 2020
- Messages
- 1,703
I just looked at this and it appears that I put the table name in as the row source which is never going to works since it is unsorted. I put the sorted query in there and it worked properly again. You are right about the value list getting saved because that is exactly what happened when I attempted to test add and delete code. It just jacked everything up. The question now is how do I delete or add an item to the listbox? I have the same Add and Delete button on my original form that works properly.
Edit: I see how it works now, this works. It needs some further validation in there, but the basic functionality is there.
Edit: I see how it works now, this works. It needs some further validation in there, but the basic functionality is there.
Code:
Private Sub DeleteBtn_Click()
Dim SelectedRank As Long
If Nz(Me!ITID) = 0 Then Exit Sub
SelectedRank = Me!Rank
If MsgBox("About to DELETE " _
& DLookup("IDescription", _
"ItemType", _
"ITID=" & Me!ITID) & ", OK?", vbYesNo) = vbYes Then
ListSorter.delItem (SelectedRank - 1)
ListSorter.UpdateTableSortOrder "itemtype", "ITID", "RANK"
UpdateRankColumn
DoCmd.RunCommand acCmdDeleteRecord
End If
End Sub
Last edited: