Connecting Tech Pros Worldwide Forums | Help | Site Map

Pimary Key as date type, bug finding record

Newbie
 
Join Date: Sep 2006
Posts: 1
#1: Sep 20 '06
I'm new at access and i'm dealling with a simple problem on positioning the form record seeking a date primary field.

I have simple table with two data fields:
1- date field as short-date (primary field)
2 - description field as text

Every time i try to use a me.recordsetclone.findfirst to match a date starting with a zero (i.e 02-09-2006) it gives me nomatch but the record exists! If the date doesn't start with zero (i.e 20-09-2006) it matches the record.

How is this possible? Am i doing something wronge?

I retreive the dates from clicking in a listbox and it's rowsource is the date field from the table "MyDates"

The code i use is this:

Private Sub List0_Click()

With Me
.RecordsetClone.FindFirst "[MyDates] = #" & me.list0 & "#"
If Not .RecordsetClone.NoMatch Then
.Bookmark = .RecordsetClone.Bookmark
.Recordset.Bookmark = .RecordsetClone.Bookmark
Else
MsgBox ("Record not found")
End If
End With

End Sub

Thank you.

Note: i've tried "dlookup" method and it gives me the same results.
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,866
#2: Sep 21 '06

re: Pimary Key as date type, bug finding record


Although you see the date with a 0 this is a format not a value the value is only the 2 not the 02.

To find a date less than the 10th of the month use

Day([DateField])<10


Quote:

Originally Posted by Pedro Pinto

I'm new at access and i'm dealling with a simple problem on positioning the form record seeking a date primary field.

I have simple table with two data fields:
1- date field as short-date (primary field)
2 - description field as text

Every time i try to use a me.recordsetclone.findfirst to match a date starting with a zero (i.e 02-09-2006) it gives me nomatch but the record exists! If the date doesn't start with zero (i.e 20-09-2006) it matches the record.

How is this possible? Am i doing something wronge?

I retreive the dates from clicking in a listbox and it's rowsource is the date field from the table "MyDates"

The code i use is this:

Private Sub List0_Click()

With Me
.RecordsetClone.FindFirst "[MyDates] = #" & me.list0 & "#"
If Not .RecordsetClone.NoMatch Then
.Bookmark = .RecordsetClone.Bookmark
.Recordset.Bookmark = .RecordsetClone.Bookmark
Else
MsgBox ("Record not found")
End If
End With

End Sub

Thank you.

Note: i've tried "dlookup" method and it gives me the same results.

Reply