listview implementation

nisha

Registered User.
Local time
Today, 13:20
Joined
Aug 18, 2009
Messages
22
hi,

i want help to implement the following logic.

i have a table like this below:
id description order
k1 test1 1
k2 test2 2
k3 test3 3

now i want to load this data into a listview in front end arranging according to the order
like
test1
test2
test3.

Till here i have implemented.
now comes the problem.. well i would not call ita problem might be its silly for ppl out there..[:)]

i want the user to move the listview items as n how they want. i.e rearange the items on click of a button(moveup or down) and then on click of save update the same order in the database.

i.e if user rearranges the listview item like below
test3
test1
test2

then in the database i want to update the order
k1 test1 2
k2 test2 3
k3 test3 1

Any help and suggestion for implementing the same.
 
So all you need to do is exchange the locations of two things. To do this you need a third location, and here's the code.
Code:
C=A
A=B
B=C
A takes the value of B, and B takes the value of A.

Here's part of a module that does this job with objects in an array. This routine receives the list index of the item to move. Array position zero is used as the 'third' location.
Code:
Sub MoveUp(ByVal ListIndex As Long)
   If ListIndex > 1 Then
[COLOR="Green"]      'move the selected item to position zero[/COLOR]
      Set m_items(0) = m_items(ListIndex)
[COLOR="Green"]      'move the item above down[/COLOR]
      Set m_items(ListIndex) = m_items(ListIndex - 1)
[COLOR="Green"]      'move the selected item up[/COLOR]
      Set m_items(ListIndex - 1) = m_items(0)
      Set m_items(0) = Nothing
   End If
End Sub
Maybe that gives you some ideas.
 
I am using this following code to move the list item down. but some how its not working.. please let me know wht needs to be done.....

Private Sub cmdDown_Click()
On Local Error Resume Next
If lvwLinks.SelectedItem.Index < lvwLinks.ListItems.Count Then
Dim strTemp As String
strTemp = lvwLinks.ListItems(lvwLinks.SelectedItem.Index + 1).Text
lvwLinks.ListItems(lvwLinks.SelectedItem.Index + 1).Text = lvwLinks.ListItems(lvwLinks.SelectedItem.Index).Text
lvwLinks.ListItems(lvwLinks.SelectedItem.Index).Text = strTemp
lvwLinks.ListItems(lvwLinks.SelectedItem.Index).Selected = False
lvwLinks.ListItems(lvwLinks.SelectedItem.Index + 1).Selected = True
lvwLinks.SetFocus
Else
MsgBox "You cannot move this item dpwn - already at the bottom!", vbOKOnly Or vbExclamation, "Error"
End If
End Sub
 
You need to describe the problem in greater detail than, "somehow it's not working."
Cheers,
 
oh ok...

the problem is though i select an item to move it down the statements in the code are getting executed fine but still the list view items remain in the same order. I want anyone to validate on the logic i have tried to implement.
 
Have thown together as very simple simulation of what you want. It needs finetuning regarding validation and error messages. You also need to click on the item in the listbox prior to clicking on the directional arrow.

David
 

Attachments

thanks for the code..

But still its not working... is there any difference between a listview and a list box.. the sample mdb is using list box but in my code i am using listview control.

StrItem = lvSeqList.ListItems(nIndex).Text
Me.lvSeqList.RemoveItem (nIndex)
Me.lvSeqList.AddItem StrItem, nIndex - 1
Me.lvSeqList.SetFocus



i changed the methods of the listview corresponding to the listbox methods as per ur exmaple but still no difference... i am missing anything:confused:
 
Where have you got this list view control from? is it an ActiveX component? What version of Access are you using?

Is it the MS Listview control I have just found in Activex controls?

Can you provide a copy of what you have so far?

David
 
i am using access 2003 version. The control class reads "ListViewCtrl"
and OLE class reads "MSComctlLib.ListViewCtrl.2". yes its an active x control
 
Whoops, I bet it's your error handling. 'On Error Resume Next' suppresses ALL errors so your code only LOOKS like it runs...
 
sorry for the late response.. was stuck up with some other issue. However.. have not got any solution for the same.[:(]

I have used on error goto statement and no errors. The code is executing fine and finally the focus is also getting set. Let me know anyone wht else next..:confused:
 
Remove your error handler and rerun your procedure. See what happens...
 
thanks for ur response.. i used listbox instead of listview n now it works fine... [:)]

Thanks all...
 

Users who are viewing this thread

Back
Top Bottom