• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Assistance with listview

Fred Wayne

Member
I have created a simple database, but I need that when I enter a new value, that value to be displayed to top of the ListView and not on the bottom. What I need is to order from newer to older according to the date. Is this possible to be done?

I would appreciate the assistance.
 

Attachments

  • Motor de Busqueda (2).xlsm
    525.9 KB · Views: 8
I am using this code in the Initiallze envent to try to sort the listview, however it seems not to be working.
Code:
Dim Fx As Integer
Dim LI As ListItem

With EX3.ListView1
.Gridlines = True
.CheckBoxes = False
.View = lvwReport
.FullRowSelect = True
.SortOrder = lvwDescending


With .ColumnHeaders
        .Clear
        .Add , , "Sku Code", 70
        .Add , , "Receipt Description", 150, 0
        .Add , , "Date", 95, 1
        .Add , , "NISE Number", 80, 1
        .Add , , "Amount", 100, 1
        .Add , , "Month", 100, 0
        .Add , , "Due Date", 95, 0
        .Add , , "Status", 70, 1
        .Add , , "Payment Date", 95, 0
        .Add , , "Invoice #", 100, 0
        End With
End With
 

Attachments

  • Motor de Busqueda Wayne.xlsm
    509.9 KB · Views: 6
Ohh I understand. Thank you. My native languaje is not English neither. I think many of us are just beginners or want to expand our limited knowledge and being as experts like you all are. I just wanted some guidance but I feel scolded instead. I do really appreciate it. I will try to do it myself. For many of us(incluiding myself) think you are like Gods in excel, and I will keep thinking that way, it won't change. But Thank you both of you anyway. Best regards from Costa Rica. God Bless you all.
 
Thank you @Belleke for taking your time and asking. My problem has not been resolved yet. However, I'm working on it at the moment. I am searching for it in another sources. I will let you know just in case I don't get to the bottom of it. Thank you @Belleke . As ussually, you are simply the best. God Bless you all the time.
 
Fred, for a ListView you have forgotten at the end of the Initialize event to just set .SortKey and .Sorted …​
But as you load text within the ListView rather than the numeric date value then the sort won't work as you expect​
so the easy way is again to sort first the worksheet data.​
If you prefer to not sort the data within the worksheet but within the ListView then​
you have to add a hidden column storing the data value rather than text and set SorKey on this column index - 1 …​
 
I handled by adding this code in Module2:
Code:
Sub ORDER_LIST()
Dim TOTAL_DATA As Range
Dim SPECIFIC_COLUMN As Range

Set TOTAL_DATA = Worksheets("Items").Range("A:J")
Set SPECIFIC_COLUMN = Worksheets("Items").Range("C:C")

TOTAL_DATA.Sort Key1:=SPECIFIC_COLUMN, Order1:=xlDescending, Header:=xlYes

Worksheets("items").Cells(1, 3).Select

End Sub

It worked perfectly.
On the other hand, How can I delete an item that has been entered, I created an ComnmandButton called "cmdDelete", How can I make thiis button to delete the chosen item?
Another thing that I have noticedm is that each time I enter a new value, the totals label on the lower side of the form does not updates the amounts.
1697901311821.png
 

Attachments

  • Motor de Busqueda Wayne.xlsm
    527.1 KB · Views: 5
I have fixed the issue of the Totals Label Amout just by adding a simple code to the SUBMIT CommandButton:
Code:
EX3.sum = Sheets("TOTALS").Range("B1").Value
I am still have pending how to delete from items sheet when chosen from the listview and click on cmdDelete CommandButton
 
Code:
Private Sub cmdDelete_Click()
Set ws = Worksheets("Items")
Set Rng = [SK]
Set fnd = Rng.Find(What:=ListView1.SelectedItem, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
ws.Rows(fnd.Row).Delete
   End Sub
Make a defined name range (first column in your Listview) in Formulas -> Name manager (as example I called it SK (Sku Code) and use the code in your delete button
 
It worked amazing. Now let find out to how to refresh the data from main userform because the deleted item is sitll displayed on the listvew, but when I reopen the form, the deleted item is finaly not displayed.
 
Only one thing. It is almost nothing, but why the totals lable uipdates when editing an item but when entering a new item, it does not update the amount- I am using the same code but it shows me an error.
1697909771980.pngThis is the code that shows me the error: EX3.sum.Caption = Format(sum.Caption, "¢#,###,###0.00")
1697909956464.png1697909989498.png
What can I do to solve this?
 

Attachments

  • Motor de Busqueda Wayne.xlsm
    553.9 KB · Views: 5
What I did was just to add a new commandbutton, named it "REFRESH" and set the code to do the thing:
1697913928067.png
Code:
Private Sub REFRESH_Click()
Call cargalista
Call ORDER_LIST
EX3.sum = Sheets("TOTALS").Range("B1").Value
EX3.sum.Caption = Format(sum.Caption, "¢#,###,###0.00")
End Sub

With this it worked great, but if there is another another way that can be suggestted, it woul be so appreciated.
 
Hello. I've been updating my personal search engine file, I feel like it's going pretty well. I have wanted to add a listbox to the forms called AYA_RUBRICS, COOPEG, AND LIBERTY so that they can show me the data entered in the corresponding sheets. I have tried to do it first with the form called AYA_RUBRICS, but I have not been able to do it.
How can I achieve this?
Thank you very much in advance for the help provided.
 

Attachments

  • Motor de Busqueda.xlsm
    874.7 KB · Views: 8
Back
Top