SELECT MAX(...) returns 0

  • Thread starter Thread starter Pascal Biston
  • Start date Start date
P

Pascal Biston

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
 
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:
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 ?

Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
Hi,

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

Regards,

Pascal

Jan Hyde said:
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:
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 ?

Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
What's your code look like: how are you referring to the field when you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Pascal Biston said:
Hi,

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

Regards,

Pascal

Jan Hyde said:
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:
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 ?

Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
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.
 
Yes, I refer rs(0)

Douglas J. Steele said:
What's your code look like: how are you referring to the field when you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Pascal Biston said:
Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le message de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Pascal Biston said:
Yes, I refer rs(0)

Douglas J. Steele said:
What's your code look like: how are you referring to the field when you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Pascal Biston said:
Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le message de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
Hi,

Try like below, it should work:

SELECT MAX(NumChant) as NumC From Chant


Then use the alias instead NumChant.









Douglas J. Steele said:
Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Pascal Biston said:
Yes, I refer rs(0)

Douglas J. Steele said:
What's your code look like: how are you referring to the field when you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le
message
de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
rs(0) should work, or rs.Fields(0)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


SaGdy said:
Hi,

Try like below, it should work:

SELECT MAX(NumChant) as NumC From Chant


Then use the alias instead NumChant.


Douglas J. Steele said:
Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Pascal Biston said:
Yes, I refer rs(0)

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> a écrit dans le
message de What's your code look like: how are you referring to the field when you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le message
de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
I think like this:

maxN=rs.Fields(NumC)

'maxN' get MAX of NumChant



Douglas J. Steele said:
rs(0) should work, or rs.Fields(0)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


SaGdy said:
Hi,

Try like below, it should work:

SELECT MAX(NumChant) as NumC From Chant


Then use the alias instead NumChant.


Douglas J. Steele said:
Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Yes, I refer rs(0)

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> a écrit dans le
message de What's your code look like: how are you referring to the field
when
you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le message
de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
Yeah, but we'll never know unless Pascal shows us his code, will we?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


SaGdy said:
I think like this:

maxN=rs.Fields(NumC)

'maxN' get MAX of NumChant



Douglas J. Steele said:
rs(0) should work, or rs.Fields(0)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


SaGdy said:
Hi,

Try like below, it should work:

SELECT MAX(NumChant) as NumC From Chant


Then use the alias instead NumChant.


Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Yes, I refer rs(0)

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> a écrit
dans
le
message de What's your code look like: how are you referring to the field when
you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le
message
de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
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 said:
Yeah, but we'll never know unless Pascal shows us his code, will we?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


SaGdy said:
I think like this:

maxN=rs.Fields(NumC)

'maxN' get MAX of NumChant



Douglas J. Steele said:
rs(0) should work, or rs.Fields(0)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Hi,

Try like below, it should work:

SELECT MAX(NumChant) as NumC From Chant


Then use the alias instead NumChant.


Please show the code you're using. It's practically impossible to solve
problems by groping around in the dark!

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Yes, I refer rs(0)

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> a écrit dans
le
message de What's your code look like: how are you referring to the field when
you
retrieve it from the recordset?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Hi,

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

Regards,

Pascal

"Jan Hyde" <[email protected]> a écrit dans le
message
de
"Pascal Biston" <[email protected]>'s wild thoughts were
released on Thu, 6 May 2004 11:07:43 +0200 bearing the
following fruit:

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 ?


Is there a where clause on the SQL?



--
Jan Hyde (MVP - Visual Basic)

Ramadan is fast approaching. (Priscilla H Ballou)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
 
Back
Top