473,699 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.RecordsetClo ne.FindFirst "[BillDate] = #" & Me![Combo2] & "#"
If RecordsetClone. NoMatch Then
MsgBox "No Match"
Else
Me.Bookmark = Me.RecordsetClo ne.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 16387
-----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.RecordsetClo ne
With rs
.FindFirst "[BillDate] = " & CDate(Me![Combo2])
If .NoMatch Then
MsgBox "No Match"
Else
Me.Bookmark = .Bookmark
End If
End With

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

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

iQA/AwUBQkoHVYechKq OuFEgEQLN1ACg2D LBdaDZMTgoGJWsf 0X7GJzh2MsAoIHH
gS3bNHVyLjyPMHJ oe6/mTCWC
=YzG8
-----END PGP SIGNATURE-----
jo*******@btint ernet.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.RecordsetClo ne.FindFirst "[BillDate] = #" & Me![Combo2] & "#"
If RecordsetClone. NoMatch Then
MsgBox "No Match"
Else
Me.Bookmark = Me.RecordsetClo ne.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*******@btint ernet.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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQkr+BYechKq OuFEgEQKF2wCg/TCsabdFsrSQDbIs NpGt19VGPOUAn29 C
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
3162
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 ..Fields.Append .CreateField("CT_ID", dbLong) ..Fields.Append .CreateField(strTmpIDFld, dbLong) ..Fields.Append .CreateField(strTmpDateFld, dbDate) ..Fields.Append .CreateField(strTmpDataFld, dbDouble)
0
1313
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. I have worked out why it does this, but i am not sure how to change it. (I have tried quite a few things to no avail). The current code uses "findfirst" to select from a query the first appointment on the correct date. If IsDate(f("date" & i)) Then myDate = Format((f("date" & i)),...
2
2454
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 name of the first appointment on each day into the same date in a calendar form. If rs.RecordCount 0 Then For i = 1 To 37 If IsDate(f("date" & i)) Then
1
6715
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 other people have had trouble with FindFirst and FindNext, so I hope this will be helpful! 'This is the counter to help with FindNext Dim vblCnt As Integer Private Sub btnSearch_Click() On Error GoTo Err_btnSearch_Click Dim vblSearch As String Dim vblRSC As Recordset
2
1714
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 found on the web. The code appears to work, but for some reason early dates in May 2007 although present in the holidays table are not being found by the find first statement in the code. For example bank holiday 07/05/2007 is being classed as working day, but 28/05/2007 is not despite both being...
7
19617
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 separately as an argument in FindFirst, but NOT in combination with one another. I tried various combinations of quotes, double quotes, brackets and paranthesis but in case of using 2 conditions I'm still receiving the error message saying "run-time error 13 - type mismatch". If I use just one of...
3
3277
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 entry on this website. My problems begin in that my Database does not appear to recognise "FindFirst". The sample database I downloaded for help does recognise the script and when I begin to type the drop down gives the prompt for "FindFirst"! Why is it that my MDB does not? The only drop downprompt...
2
3648
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 " abbrevations. On a testing form I go to a record with double or single quotes in the location description and click a button to see if Access can tell me the ID number and find its way back to the original record. When the text contains double quotes the FindFirst works but the Dloookup...
25
3914
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 FindIt() Dim db As Database, rs As Recordset Dim sCriteria As String Set db = DBEngine.Workspaces(0).Databases(0) Set rs = db.OpenRecordset("tblTest", dbOpenDynaset)
0
8706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8633
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
5891
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3076
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2016
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.