•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 456,529 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,754 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 3979 | Replies: 3
![]() |
| |
•
•
Join Date: Aug 2004
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hai ,
i am getting the correct result for the below query
rs.Open "SELECT DISTINCT RepTL From PEList WHERE RepFL='" & CriteriaName & "'", Cnn, adOpenStatic, adLockReadOnly, adCmdText
but the thing is i need to display the record in the Order by RepId, but when i add RepId in the query its shows more records and not the distinct RepTL when i write as below
rs.Open "SELECT DISTINCT RepTL,RepId From PEList WHERE RepFL='" & CriteriaName & "'", Cnn, adOpenStatic, adLockReadOnly, adCmdText
what is the way to display the records order by Id and the RepTL should be distinct.
Kindly suggest me.
Thank you,
Chock.
i am getting the correct result for the below query
rs.Open "SELECT DISTINCT RepTL From PEList WHERE RepFL='" & CriteriaName & "'", Cnn, adOpenStatic, adLockReadOnly, adCmdText
but the thing is i need to display the record in the Order by RepId, but when i add RepId in the query its shows more records and not the distinct RepTL when i write as below
rs.Open "SELECT DISTINCT RepTL,RepId From PEList WHERE RepFL='" & CriteriaName & "'", Cnn, adOpenStatic, adLockReadOnly, adCmdText
what is the way to display the records order by Id and the RepTL should be distinct.
Kindly suggest me.
Thank you,
Chock.
•
•
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 191
Reputation:
Rep Power: 5
Solved Threads: 1
•
•
•
•
Originally Posted by chock
Hai ,
i am getting the correct result for the below query
rs.Open "SELECT DISTINCT RepTL From PEList WHERE RepFL='" & CriteriaName & "'", Cnn, adOpenStatic, adLockReadOnly, adCmdText
but the thing is i need to display the record in the Order by RepId, but when i add RepId in the query its shows more records and not the distinct RepTL when i write as below
rs.Open "SELECT DISTINCT RepTL,RepId From PEList WHERE RepFL='" & CriteriaName & "'", Cnn, adOpenStatic, adLockReadOnly, adCmdText
what is the way to display the records order by Id and the RepTL should be distinct.
Kindly suggest me.
Thank you,
Chock.
How can you order by RepID and have the DISTINCT clause on RepTL? Lets say you have two records with RepTL="foo", one with RepID=8 and the other with RepID=12. How does the distinct query know what RepID to use? So, of course it will put a record for both, and thus your distinct clause is rendered useless.
I think you need to rethink what you are trying to do.
Mark
Mark Nemtsas
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
•
•
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 191
Reputation:
Rep Power: 5
Solved Threads: 1
Hi There,
Try doing it manually,
Something like:
Select RepTL,RepID From PEList WHERE RepFL='foo' ORDER BY RepTL ASC, RepID DESC;
Then loop through the record set taking note of when RepTL changes and recording RepID which is the highest ID (or change the sort order). Something like:
Cheers,
Mark
Try doing it manually,
Something like:
Select RepTL,RepID From PEList WHERE RepFL='foo' ORDER BY RepTL ASC, RepID DESC;
Then loop through the record set taking note of when RepTL changes and recording RepID which is the highest ID (or change the sort order). Something like:
strLastRepTL=""
Do
if strLastRepTL<>rs.fields("RepTL").value then
debug.print "New LastRepTL found, RepID-" & rs.fields("RepID").value
strLastRepTL=rs.fields("RepTL").value
endif
rs.MoveNext
Loop until rs.eofCheers,
Mark
Mark Nemtsas
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
Time and Billing Software - Time Tracking Software - Roller Shutters - Roller Blinds -
Baby Books
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Modify Record script doesn't add/change info (PHP)
- Add a Voice Message to an E-Mail Message (Windows tips 'n' tweaks)
- Perplexed: Combo Box Not Holding Data (C#)
- Oracle reports: Continous horizontal fields (Oracle)
- Why Data Structures???...QUESTIONS INSIDE (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: program design
- Next Thread: Autonumbering?


Hybrid Mode