Access Query MAX function return value

L

Landon

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.
 
M

Michel Walsh

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top