Problem finding a DATE (TIME) field using ADO and VB6 
Author Message
 Problem finding a DATE (TIME) field using ADO and VB6

I am try to do a find on a date field that contains only the time part and
have problems getting it to work.

I am using ADO to access and Access 97 database using VB6. I have tried
this:

adodc.recordset.find "[TimeLogged] = #15:30:00 PM#"

This sets adodc.recordset.eof to true.

adodc.recordset.find "[TimeLogged] = '15:30:00 PM'"

This sets adodc.recordset.eof to false meaning that the record is found. BUT
the recordset is not position to the 'found' record.

My database contains a table where the "TimeLogged" field is defined as a
date data type but only store the time part of it.

There is a record containing 15:30:00 PM.

Can someone please help?

TIA
Young



Wed, 18 Jun 1902 08:00:00 GMT  
 Problem finding a DATE (TIME) field using ADO and VB6

Quote:

> I am try to do a find on a date field that contains only the time part and
> have problems getting it to work.
> I am using ADO to access and Access 97 database using VB6. I have tried
> this:

> adodc.recordset.find "[TimeLogged] = #15:30:00 PM#"

> This sets adodc.recordset.eof to true.

> adodc.recordset.find "[TimeLogged] = '15:30:00 PM'"

> This sets adodc.recordset.eof to false meaning that the record is found. BUT
> the recordset is not position to the 'found' record.
> My database contains a table where the "TimeLogged" field is defined as a
> date data type but only store the time part of it.
> There is a record containing 15:30:00 PM.

  I tried this on one of my tables (Access97, Date/Time field set to
Long Time format).  Both syntaxes found the correct record, so for me it
doesn't appear to matter whether the # or ' symbol is used - either way,
I am positioned at the correct record.
  In your case, is the adodc used as a DataSource for any other
control?  Could you post the code by which you determine the active
record after the Find?  I'm wondering if something else in your design
prevents the adodc.recordset from positioning to the right record, or
could it be moving but you're not detecting it properly?  Also, what are
the adodc CursorLocation, CursorType, and LockType (just curious)?
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"
 ((("What's so funny 'bout peace, love & understanding?" - Nick Lowe)))


Wed, 18 Jun 1902 08:00:00 GMT  
 Problem finding a DATE (TIME) field using ADO and VB6
Are you quite sure that the value in the database is exactly 15:30:00?
If the value was place in the recordset by using a timestamp, it may
not be EXACTLY 15:30:00. You may need to do some rounding or a range
check... like TimeLogged >= 15:30:00 and less than 15:30:01

On Fri, 19 May 2000 16:42:20 +1000, "Young Lim"

Quote:

>I am try to do a find on a date field that contains only the time part and
>have problems getting it to work.

>I am using ADO to access and Access 97 database using VB6. I have tried
>this:

>adodc.recordset.find "[TimeLogged] = #15:30:00 PM#"

>This sets adodc.recordset.eof to true.

>adodc.recordset.find "[TimeLogged] = '15:30:00 PM'"

>This sets adodc.recordset.eof to false meaning that the record is found. BUT
>the recordset is not position to the 'found' record.

>My database contains a table where the "TimeLogged" field is defined as a
>date data type but only store the time part of it.

>There is a record containing 15:30:00 PM.

>Can someone please help?

>TIA
>Young



Wed, 18 Jun 1902 08:00:00 GMT  
 Problem finding a DATE (TIME) field using ADO and VB6
Young,

Perhaps adding the other "find" parameters might help...

[SkipRecords As Long],
[SearchDirection As SearchDirectionEnum = adSearchForward],
[Start]

I got a strange error when I did not use them (the rowset cannot scroll
backwards?)

This worked for me:

set con = new ADODB.Connection
con.open ("DSN=testdb")
set myrs= con.execute ("select * from table1")
myrs.find "TimeLogged = #15:30:00 PM#", 0, 1, 1
?myrs.fields(0).value

This put me on record 2

HTH

-Mike



Quote:
> I am try to do a find on a date field that contains only the time part
and
> have problems getting it to work.

> I am using ADO to access and Access 97 database using VB6. I have
tried
> this:

> adodc.recordset.find "[TimeLogged] = #15:30:00 PM#"

> This sets adodc.recordset.eof to true.

> adodc.recordset.find "[TimeLogged] = '15:30:00 PM'"

> This sets adodc.recordset.eof to false meaning that the record is
found. BUT
> the recordset is not position to the 'found' record.

> My database contains a table where the "TimeLogged" field is defined
as a
> date data type but only store the time part of it.

> There is a record containing 15:30:00 PM.

> Can someone please help?

> TIA
> Young

Sent via Deja.com http://www.deja.com/
Before you buy.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem find a DATE (TIME) field using ADO

2. Finding date field using LIKE operator using ADO

3. ADO with Access Date/Time field not storing the time, just the date

4. Problem Using Time Part of a Date-Time field in SQL-Server

5. Find a date field using LIKE and ADO

6. Finding a date field using LIKE and ADO

7. Problem with VB6 program using Access database and Date field

8. Matching system date/time with field date/time

9. ADO Date/Time fields

10. Using ADO w/ADO data control date problems

11. start date/time, end date/time problem

12. Find / Restrict using date and time

 

 
Powered by phpBB® Forum Software