|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? =( |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > FindFirst for date field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|