PC Review


Reply
Thread Tools Rate Thread

Access Query MAX function return value

 
 
Landon
Guest
Posts: n/a
 
      9th Sep 2008
Hi I use Visual C++ MFC 4.2.

I need to get the last support_code from the table so I make query like this:
CString sSQL;
sSQL.Format( "SELECT MAX( support_no ) AS \"last\" FROM history WHERE
support_no LIKE \'%s*\'", sYear );

I have tested it in the MS Access and it worked fine.

It should return Support Code in the form like this: "S08-00012" so it has S
and - characters inside.

Now. the problem is from the programming side.

rs.Open( CRecordset::forwardOnly, ( sSQL ) );

CString sSupportNo;
CString sNextCounter;

if( !rs.IsEOF() ){
rs.GetFieldValue( "last", varSupportNo );
ASSERT( varSupportNo.m_dwType == DBVT_STRING );

sSupportNo = *varSupportNo.m_pstring;
}

The error is at the ASSERT part. I know the error but I don't know how to
fix it.
The point is that the value of field "last" is not a CString. I don't know
what it is, because I also have tried DOUBLE type it neither work.

What is the return value of MAX to my code?

Thank you very much.
 
Reply With Quote
 
 
 
 
Michel Walsh
Guest
Posts: n/a
 
      9th Sep 2008
I doubt it is a CString or any value type since it must hold the VALUE NULL
(not NULL as a pointer for the object variable holding the data, but as a
value for the data it represents). It is probably derived from an UNION
allowing you to represent the VB/VBA Variant datatype, but which union
typedef exactly is dependant of the library you use (and it is too long I
used them to relay on my memory to supply more details), but right now, I
think http://msdn.microsoft.com/en-us/library/ms808313.aspx can help.

Vanderghast, Access MVP


"Landon" <(E-Mail Removed)> wrote in message
news:602E8AB6-C7CF-47E1-AD93-(E-Mail Removed)...
> Hi I use Visual C++ MFC 4.2.
>
> I need to get the last support_code from the table so I make query like
> this:
> CString sSQL;
> sSQL.Format( "SELECT MAX( support_no ) AS \"last\" FROM history WHERE
> support_no LIKE \'%s*\'", sYear );
>
> I have tested it in the MS Access and it worked fine.
>
> It should return Support Code in the form like this: "S08-00012" so it has
> S
> and - characters inside.
>
> Now. the problem is from the programming side.
>
> rs.Open( CRecordset::forwardOnly, ( sSQL ) );
>
> CString sSupportNo;
> CString sNextCounter;
>
> if( !rs.IsEOF() ){
> rs.GetFieldValue( "last", varSupportNo );
> ASSERT( varSupportNo.m_dwType == DBVT_STRING );
>
> sSupportNo = *varSupportNo.m_pstring;
> }
>
> The error is at the ASSERT part. I know the error but I don't know how to
> fix it.
> The point is that the value of field "last" is not a CString. I don't know
> what it is, because I also have tried DOUBLE type it neither work.
>
> What is the return value of MAX to my code?
>
> Thank you very much.



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Query MAX Function Return Value Landon Microsoft Access 1 9th Sep 2008 09:45 AM
Access Query Max Function Return Value Landon Microsoft Access 1 9th Sep 2008 09:44 AM
Access Query MAX Function Return Value Landon Microsoft Access Queries 0 9th Sep 2008 05:59 AM
Return of old Access Error "you tried to execute a query that does not include the specified expression ... as part of the aggregate function" harmindersingh.singapore@gmail.com Microsoft Access Queries 4 13th Oct 2006 06:32 PM
VBA Public function used to return Criterion to Query - return "*" =?Utf-8?B?YWxleGhhdHppc2F2YXM=?= Microsoft Access VBA Modules 4 6th Aug 2005 03:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:45 PM.