472,353 Members | 1,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

FindFirst with a Date Field

I have a table in Access 97 with [BillDate] a Date/Time type field
Formated "Short Date", UK local settings (dd/mm/yy).

Want to go to a record with a date selected from a combo (correctly
Short Date formatted) on a form.

Me.RecordsetClone.FindFirst "[BillDate] = #" & Me![Combo2] & "#"
If RecordsetClone.NoMatch Then
MsgBox "No Match"
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

Code works fine for dates up to 31/12/00 but produces No Match for
dates > 01/01/01. I'm aware of most of the issues re ambiguous date
formats but can't find anything on the Web for this specific issue.

All help much appreciated.

TIA

Nov 13 '05 #1
4 16069
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You may wish to try converting the ComboBox's value to a date:

' It's better to have an obj ref variable, rather than the complete obj.
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
With rs
.FindFirst "[BillDate] = " & CDate(Me![Combo2])
If .NoMatch Then
MsgBox "No Match"
Else
Me.Bookmark = .Bookmark
End If
End With

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQkoHVYechKqOuFEgEQLN1ACg2DLBdaDZMTgoGJWsf0X7GJ zh2MsAoIHH
gS3bNHVyLjyPMHJoe6/mTCWC
=YzG8
-----END PGP SIGNATURE-----
jo*******@btinternet.com wrote:
I have a table in Access 97 with [BillDate] a Date/Time type field
Formated "Short Date", UK local settings (dd/mm/yy).

Want to go to a record with a date selected from a combo (correctly
Short Date formatted) on a form.

Me.RecordsetClone.FindFirst "[BillDate] = #" & Me![Combo2] & "#"
If RecordsetClone.NoMatch Then
MsgBox "No Match"
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

Code works fine for dates up to 31/12/00 but produces No Match for
dates > 01/01/01. I'm aware of most of the issues re ambiguous date
formats but can't find anything on the Web for this specific issue.

Nov 13 '05 #2
Rog
Jon,

Access gets confused with non-American date settings, you can either
convert the dates as MGFoster suggests, or use Dev Ashish's solution:
http://www.mvps.org/access/datetime/date0005.htm

Nov 13 '05 #3
> .FindFirst "[BillDate] = " & CDate(Me![Combo2])

Thanks but the above gives a "Division by zero" error.

..FindFirst "[BillDate] = #" & Format(Me![Combo2], "mm\/dd\/yy") & "#"

is the only way I could get it working. I was interested in the pre
and after Y2K issue and if this was a known bug.

Jon

Nov 13 '05 #4
jo*******@btinternet.com wrote:
.FindFirst "[BillDate] = " & CDate(Me![Combo2])

Thanks but the above gives a "Division by zero" error.

.FindFirst "[BillDate] = #" & Format(Me![Combo2], "mm\/dd\/yy") & "#"

is the only way I could get it working. I was interested in the pre
and after Y2K issue and if this was a known bug.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I couldn't replicate the error in the debug window. CDate() worked on
these variations:

1/1/00 -> 1/1/2000
1/1/0 -> 1/1/2000
01/01/01 -> 1/1/2001

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQkr+BYechKqOuFEgEQKF2wCg/TCsabdFsrSQDbIsNpGt19VGPOUAn29C
IxW7nUTUi/jKd6QF2UqY7pkg
=Mh7C
-----END PGP SIGNATURE-----
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rivka.howley | last post by:
I wrote some code that creates a table with a date/time field at 15-minute intervals. Here's how I create and populate the table With tblDataTemp...
0
by: keri | last post by:
I have a calendar that currently shows the name of a customer in the correct date. However it does not show multiple appointments on the same day....
2
by: keri | last post by:
Hi everyone, I'm using findfirst in code as below. It searches a query that shows appointment date and account name and should return the account...
1
Corster
by: Corster | last post by:
I went through a great deal of hassle to figure this out for myself, but now it is complete, I would like to share it with the world! I know afew...
2
by: JasCot75 | last post by:
Hello all, my first go at this so please be gentle. I'm putting together a simple access database and have run into a problem with date function I...
7
by: waltvw | last post by:
I'm using FindFirst method in Access VBA to find a particular record in a recordset. I have 2 search criteria each of which works just fine if used...
3
by: boliches | last post by:
I am trying to get a continuous form to highlight lines individually (ideally on hover). I have used the following code as recommended by a previous...
2
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and...
25
by: Rick Collard | last post by:
Using DAO 3.6 on an Access 2002 database, I'm getting unexpected results with the FindFirst method. Here's the simple code to test: Public Sub...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.