Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 13th, 2006, 03:40 AM
Dmitry Perets Dmitry Perets is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 7 Dmitry Perets User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 50 m 11 sec
Reputation Power: 0
FindFirst for date field

Hello,

I am trying to implement a search based on a date field. The user enters a date and I move the form to the first record which has this date. Just that simple. Here is the code:

Dim F As Form, rst As Recordset, DateFld As String
'...
Set F = Forms![SomeForm]
DateFld = "DateField"

Set rst = F.Recordset
rst.FindFirst DateFld & "=" & CDate(Me!Date)
If rst.NoMatch Then
MsgBox "Ooops, found nothing", vbInformation
Else
Me.SetFocus
DoCmd.Close
End If

Here "Me" is the search form, "SomeForm" is the form which I want to move, "DateField" is a date field in the table which is SomeForm's control source.

The problem is that this thing just doesn't work. It can't find anything. I have implemented the same thing for other fields of SomeForm (customerID, SerialNumber etc.) and it works perfect. But not for the date!

The funniest thing is that the following DOES work:

Dim F As Form, rst As Recordset, DateFld As String
'...
Set F = Forms![SomeForm]
DateFld = "DateField"

Set rst = F.Recordset
rst.MoveFirst
While Not rst.EOF
If rst(DateFld) = CDate(Me!Date) Then
Me.SetFocus
DoCmd.Close
Exit Sub
EndIf
rst.MoveNext
Wend
MsgBox "Ooops, found nothing", vbInformation

But I don't really want this implementation, of course!
Do you have any idea what's the problem here? =(

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > FindFirst for date field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT