cte67 said:
The error msg is, "Too few parameters. Expected 1."
The code is:
//------------------------------
int OdbcRequeryFilterSort(CRecordset* pRs, CString Filter, CString Sort)
{
//Returns 0 = ok
// -1 = error
if(!OdbcIsTableOpen(pRs))
{
AfxMessageBox("OdbcRequeryFilterSort, The table is not open!");
return -1;
}
pRs->m_strSort = Sort;
pRs->m_strFilter = Filter;
try
{
pRs->Requery();
}
catch(CException* pe)
{
MessageBeep(MB_ICONEXCLAMATION);
pe->ReportError();
pe->Delete();
CString Str = _T("OdbcRequeryFilterSort--CException: ");
AfxMessageBox(Str);
return -1;
}
return 0;
}//OdbcRequeryFilterSort
//------------------------------
Okay, so this isn't really an Access question, but a .Net/ODBC/(maybe)Jet
question. But we can still probably figure out what's wrong.
Your code refers to ODBC; are you in fact querying a Jet database by way of
ODBC? Is the database in question an .mdb file or an .accdb file?
The code doesn't show the call to the function, so I can't see what you're
passing in the arguments "Filter" and "Sort". You should also post the code
that constructs those arguments and calls the function. When you step
through the code in debug mode, what values do you see for them?
The error message is one that Jet gives when you it doesn't recognize a name
in the query. We commonly see it when the name of a field is misspelled or
a text literal is not properly quoted. At the moment, I think that's the
most likely explanation, so please double-check that you haven't misspelled
the name of the field, and that the text literal is properly quoted.