PDA

View Full Version : ORDER RECORDSET BY NULL WITH DAO



sal21
09-11-2007, 04:31 AM
Ho to order entire recordset in ANAGRAFICA1 by filed APPELLATIVO where in filed APPELLATIVO is blank?
move all blank recordset in the top of table, i think ASChttp://vbcity.com/forums/smiles/wink.gif
Note: in table are present 1.202.589 rds

piece of code:

Set DB2 = DBEngine.OpenDatabase("D:\PUBBLICA\APPLICAZIONI\APPELLATIVI.MDB")
Set RSD2 = DB2.OpenRecordset("APP")
Set DB1 = DBEngine.OpenDatabase("D:\PUBBLICA\APPLICAZIONI\ANAGRAFICA_OK_10092007.mdb")
Set RSD1 = DB1.OpenRecordset("ANAGRAFICA1")


RITORNO:

With RSD1

Do While Not RSD1.EOF
If RSD1.Fields("APPELLATIVO") = "" Then
COPE = RSD1.Fields("COPE")
Call INSERISCIANAGRAFICA(COPE)
RSD1.MoveNext
Else
RSD1.MoveNext
End If
Loop

End With

malik641
09-11-2007, 05:32 AM
I'm sorry, but I don't get it.

You are looking to order a recordset by NULL values? If so, you cannot 'ORDER BY' a null column and get any desired results because NULL is 'unknown' data and therefore you would get 'unkown' results. It may never be consistent.

And what is:
Call INSERISCIANAGRAFICA(COPE) '???
Can we see the INSERISCIANAGRAFICA function/sub procedure?
And you don't use RSD2 in your code so I'm not sure what you are trying to do with it...

Could you post more of the relevant info from your code? (with some comments, since I can't read Italian [...yet])

malik641
09-11-2007, 05:39 AM
move all blank recordset in the top of table, i think ASChttp://vbcity.com/forums/smiles/wink.gif

I'm sorry, I skipped right over that. If you want to put all the NULL values on top, you can execute a query that will do that for you (you were right, ASC):

SELECT Column
FROM Table
ORDER BY Column ASC;
This is assuming there ARE NULL values in your returned data.
I think you can use that with your recordset rather than looping through the recordset.