|
-
Dec 1st, 2006, 04:22 PM
#1
Thread Starter
PowerPoster
ORDER BY problem
I am wanting to populate a ListView using the ORDER BY. I am wanting to ORDER BY on the EntryDate column which happens to be a date. It seems to work; however, its not working the way it should. Screen shots attached.
This is what I am using:
VB Code:
Public Sub PopulateListViewSQL()
strSQL = "SELECT * "
strSQL = strSQL & "FROM Ledger "
strSQL = strSQL & "WHERE AccountNumber = '" & _
frmLedger.cboAccountNumber.Text & "' "
strSQL = strSQL & "ORDER BY EntryDate DESC"
objCon.Execute strSQL
PopulateListviewEntries
End Sub
Public Sub PopulateListviewEntries()
OpenRecordset
frmLedger.lvwAccountLedger.ListItems.Clear
Do Until objRs.EOF = True
With objRs
dteEntryDate = .Fields("EntryDate")
strTransDesc = .Fields("TransDesc")
curCredit = .Fields("Credit")
curDebit = .Fields("Debit")
intID = .Fields("id")
End With
Set LvwItm = frmLedger.lvwAccountLedger.ListItems.Add(, , dteEntryDate)
With LvwItm
.SubItems(1) = strTransDesc
.SubItems(2) = Format(curCredit, "0.00")
.SubItems(3) = Format(curDebit, "0.00")
.SubItems(4) = intID
End With
objRs.MoveNext
Loop
End Sub
-
Dec 1st, 2006, 04:25 PM
#2
Re: ORDER BY problem
whats not working?
the second png looks fine.. or am i missing something?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 2nd, 2006, 07:16 AM
#3
Thread Starter
PowerPoster
Re: ORDER BY problem
 Originally Posted by Static
whats not working?
the second png looks fine.. or am i missing something?
in 1.png, 11/9/2006 comes before 11/3/2006 and it shouldnt.
in 2.png, 11/17/2006, 11/15/2006 and 11/14/2006 is coming after 11/20/2006.
In other words, I am trying to sort the records in descending order, by date. Its sorting some but not all which is a little strange.
-
Dec 2nd, 2006, 07:41 AM
#4
Re: ORDER BY problem
You are nto populating the recordset by your query. It is showing old records from another query or somewhere else.
VB Code:
Public Sub PopulateListViewSQL()
strSQL = "SELECT * "
strSQL = strSQL & "FROM Ledger "
strSQL = strSQL & "WHERE AccountNumber = '" & _
frmLedger.cboAccountNumber.Text & "' "
strSQL = strSQL & "ORDER BY EntryDate DESC"
' objCon.Execute strSQL
Set objRS = objCon.Execute strSQL '<-- Check This line
PopulateListviewEntries
End Sub
Pradeep
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|