Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find a record (DAO)

Status
Not open for further replies.

ceodav

Programmer
Feb 21, 2003
106
IT
Hi,
i'm currently working with database and i have a problem to find a date record...

i know that to find a record in a DAO object we must use "find" instruction, in fact it works with Text and numeric fields but it doesn't work for Date fields


Here it si my code:

CDaoRecordset pRecordset;
char *pRow;
char d[256];

long year=2004;
long month=1;
long day=8;

COleDateTime COleData_i(year,month,day,0,0,0);

strcpy(d,COleData_i.Format("%m/%d/%Y"));

sprintf(pRow,"Date = '%s'", d);

bool check=pRecordset.Find(AFX_DAO_FIRST,pRow);;

if (!check)
{
log_file("record not find...");

}



thanks for any suggestions...

Davide
 
It's probably the way you are formatting the date. DAO often looks for #'s on the date.

Try

strcpy(d,COleData_i.Format("#%m/%d/%Y"#));

instead of

strcpy(d,COleData_i.Format("%m/%d/%Y"));

if that still doesn't work this discussion may prove useful:
 
Sry that should be

strcpy(d,COleData_i.Format("#%m/%d/%Y#"));

small syntax error...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top