SELECT MAX(...) returns 0

message from Pascal Biston on 6 May 2004
Hi,

I've the following problem : with Windows 98, MDAC 2.8, a program write in
VB 6.0, used ADO recordset when I execute the following instance SELECT
MAX(NumChant) from ... the results is 0 but my database is not empty (+-
2500 records). The fields NumChant is varchar !

Any idea ?

Thanks to all
 
Ainars replied to Pascal Biston on 6 May 2004
AInars

"Pascal Biston" <pbi@sigroup.be> wrote in message
news:eS8SHn0MEHA.4016@TK2MSFTNGP10.phx.gbl...
 
Van T. Dinh replied to Pascal Biston on 6 May 2004
How do you define MAX of a VARCHAR Field?

In Access, this will returns the last String in the alphabetical order
(telephone directory order).

Since you use the term "varchar", it sounds like the database engine may not
be JET and the engine may have a different definition for MAX.

If you use something other than JET, you may need to check documentation of
the database engine to see how the MAX works with varchar.
 
Jan Hyde replied to Pascal Biston on 06 May 2004
"Pascal Biston" <pbi@sigroup.be>'s wild thoughts were
Is there a where clause on the SQL?
 
Pascal Biston replied to Jan Hyde on 6 May 2004
Hi,

No where clause, just a "SELECT MAX(NumChant) From Chant"

Regards,

Pascal

"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> a écrit dans le message de
news:rq1k90lfpnbhjvj1hmf8qmad18ktvcao41@4ax.com...
 
Douglas J. Steele replied to Pascal Biston on 6 May 2004
What's your code look like: how are you referring to the field when you
retrieve it from the recordset?
 
Douglas J. Steele replied to Douglas J. Steele on 10 May 2004
Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!
 
SaGdy replied to Douglas J. Steele on 13 May 2004
Hi,

SELECT MAX(NumChant) as NumC From Chant

Then use the alias instead NumChant.

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:#TKqHurNEHA.628@TK2MSFTNGP11.phx.gbl...
 
Douglas J. Steele replied to SaGdy on 13 May 2004
rs(0) should work, or rs.Fields(0)
 
SaGdy replied to Douglas J. Steele on 14 May 2004
maxN=rs.Fields(NumC)

'maxN' get MAX of NumChant

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:#hNPDKQOEHA.1644@TK2MSFTNGP09.phx.gbl...
 
Douglas J. Steele replied to SaGdy on 14 May 2004
Yeah, but we'll never know unless Pascal shows us his code, will we?
 
SaGdy replied to Douglas J. Steele on 15 May 2004
Hi, Douglas J. Steele

MDIForm1.Adodc1.RecordSource = "SELECT Max(Invc) as InvN FROM Sales"
MDIForm1.Adodc1.Refresh
CInvNo = MDIForm1.Adodc1.Recordset.Fields("InvN")

This I used in my project and I could get Max of Invc. "Invc" is a field, in
which i store # of invoices.

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:#8cl57ZOEHA.3420@TK2MSFTNGP11.phx.gbl...
 

Archived message: SELECT MAX(...) returns 0 (MS Access Forms)