If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Query for known record returns no results

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-03, 12:41
sbarnes302 sbarnes302 is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
Query for known record returns no results

I'm having a problem with retrieving existing records for an acess 2000 database in VB using DAO 3.6. I wrote the following to debug and to my surprise the msgbox does come up on some machines and certian records, always the same records each time it runs. Any ideas?

Set eqry = masterDB.OpenRecordset("select * from email", dbOpenSnapshot)
Do While Not eqry.EOF
keyu = eqry("keyu")
keyd = Str(eqry("keyd"))
Set emailRS = masterDB.OpenRecordset("select * from email where keyu = '" & keyu & "' and keyd = #" & keyd & "#", dbOpenDynaset)
If emailRS.EOF Then MsgBox "-" & keyu & "-" & keyd & "-"
eqry.MoveNext
Loop
Reply With Quote
  #2 (permalink)  
Old 02-27-03, 14:04
machado machado is offline
Registered User
 
Join Date: Feb 2003
Location: Auckland, NZ
Posts: 150
Re: Query for known record returns no results

I assume 'keyd' datatype is a Date

try formatting 'keyd' as US Date Format

keyd = Format(keyd, "mm/dd/yy")
Or
keyd = Format(keyd, "mm/dd/yy HH:MMS")

depending on if exact time is a factor


Microsoft Jet is icky with dates.

Regards,
Machado
Reply With Quote
  #3 (permalink)  
Old 02-27-03, 14:51
sbarnes302 sbarnes302 is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
Thanks but that didn't work either. I'm wondering if something really strange is going on, It only fails to get two or three out of 2000+ records? It only seems to happen on certian machine.
Reply With Quote
  #4 (permalink)  
Old 02-27-03, 14:54
machado machado is offline
Registered User
 
Join Date: Feb 2003
Location: Auckland, NZ
Posts: 150
Lightbulb

If it is just on a certain machine. Make sure that the regional settings are the same as the others.

I am not sure if this will work but give it a crack

Machado
Reply With Quote
  #5 (permalink)  
Old 02-27-03, 16:13
sbarnes302 sbarnes302 is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
Thanks, I checked that already

Check this out

SELECT * FROM email WHERE keyu='KNorris' AND keyd Between #2/27/2003 7:03:29# And #2/27/2003 7:03:31#

returns 1 record

SELECT * FROM email WHERE keyu='KNorris' AND keyd=#2/27/2003 7:03:30#

Doesn't return anything?????!?!?!

I get the same results from within Access.
If I change the record then change it back from access on my machine the record is then accessable on all machines. Repair/Compact doesn't fix it.
Reply With Quote
  #6 (permalink)  
Old 02-27-03, 16:15
machado machado is offline
Registered User
 
Join Date: Feb 2003
Location: Auckland, NZ
Posts: 150
I wonder if it is not adding split seconds.

It may be worth having a look at this.
Reply With Quote
  #7 (permalink)  
Old 02-27-03, 16:22
sbarnes302 sbarnes302 is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
Hmm... How can I tell?
Reply With Quote
  #8 (permalink)  
Old 02-27-03, 16:44
machado machado is offline
Registered User
 
Join Date: Feb 2003
Location: Auckland, NZ
Posts: 150
Because you are using jet you can add a VB Function in the SQL Query

Try this


WHERE Format(keyd, "mm/dd/yyyy HH:MMS") = #" & keyd & "#

So now you will be formatting the data you are searching before you search it. You will have to use CHR(34) for the quotation marks in the format function

Try it in Access before trying it in VB

Machado
Reply With Quote
  #9 (permalink)  
Old 02-27-03, 17:07
sbarnes302 sbarnes302 is offline
Registered User
 
Join Date: Feb 2003
Posts: 5
You are the MAN.

Ok one last thing, is there a way in access to show the datetime with milliseconds?

Thanks for your help, I really appreciate it.
Reply With Quote
  #10 (permalink)  
Old 02-27-03, 17:13
machado machado is offline
Registered User
 
Join Date: Feb 2003
Location: Auckland, NZ
Posts: 150
I Think Microsoft Jet is limited in this regard. I know SQL Server does give the option of milliseconds with a bit of fiddling.

Just search the net I am sure there is someone with the same problem.

Machado
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On