findfirst date leading zero

Z

Zedbiker

I am trying to filter records by searching for a date. However when the date
starts with a zero eg. 01/10/2006 for some reason it can't find the date. It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
J

Jeff Boyce

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data type of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be that you
actually have a Date/Time value, but you are trying to find the "formatted"
version. Or you may be using a selection criterion but not treating it as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John Spencer

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
'****Set rs = Me.Recordset.Clone
Set rs = Me.RecordsetClone 'Rather use this method

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"

If rs.NoMatch = False Then
' ****If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

End Sub


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Z

Zedbiker

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your reply.

Thanks again.

Ian

Jeff Boyce said:
It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data type of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be that you
actually have a Date/Time value, but you are trying to find the "formatted"
version. Or you may be using a selection criterion but not treating it as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
I am trying to filter records by searching for a date. However when the
date
starts with a zero eg. 01/10/2006 for some reason it can't find the date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
J

Jeff Boyce

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your
reply.

Thanks again.

Ian

Jeff Boyce said:
It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be that you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not treating it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
I am trying to filter records by searching for a date. However when the
date
starts with a zero eg. 01/10/2006 for some reason it can't find the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
Z

Zedbiker

No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

Jeff Boyce said:
Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your
reply.

Thanks again.

Ian

Jeff Boyce said:
It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be that you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not treating it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However when the
date
starts with a zero eg. 01/10/2006 for some reason it can't find the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
J

Jeff Boyce

Delimiters surround a value. For example, you use quotes to surround text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the "#" ...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

Jeff Boyce said:
Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be that
you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't find the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
Z

Zedbiker

See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

Jeff Boyce said:
Delimiters surround a value. For example, you use quotes to surround text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the "#" ...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

Jeff Boyce said:
Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be that
you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't find the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
J

Jeff Boyce

I don't know what you are using to "fill" the CmbDate combobox. Please post
the SQL of the RowSource, indicate column widths and "bound column".

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

Jeff Boyce said:
Delimiters surround a value. For example, you use quotes to surround
text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the "#"
...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

:

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be
that
you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not
treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However
when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't find
the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
Z

Zedbiker

SELECT DISTINCT Logtable.DateReported
FROM Logtable
WHERE (((Logtable.DateReported) Is Not Null And (Logtable.DateReported) Like
"*" & [Enter Search Details or "*":] & "*"))
ORDER BY Logtable.DateReported DESC;

Column Count = 1
Column Width = 2.554cm

I am sorry if I misunderstood. Should I have used "#" here instead of "*"

Regards
Ian

Jeff Boyce said:
I don't know what you are using to "fill" the CmbDate combobox. Please post
the SQL of the RowSource, indicate column widths and "bound column".

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

Jeff Boyce said:
Delimiters surround a value. For example, you use quotes to surround
text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the "#"
...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

:

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be
that
you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not
treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However
when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't find
the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
D

Douglas J. Steele

You can only use Like with text fields.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Zedbiker said:
SELECT DISTINCT Logtable.DateReported
FROM Logtable
WHERE (((Logtable.DateReported) Is Not Null And (Logtable.DateReported)
Like
"*" & [Enter Search Details or "*":] & "*"))
ORDER BY Logtable.DateReported DESC;

Column Count = 1
Column Width = 2.554cm

I am sorry if I misunderstood. Should I have used "#" here instead of "*"

Regards
Ian

Jeff Boyce said:
I don't know what you are using to "fill" the CmbDate combobox. Please
post
the SQL of the RowSource, indicate column widths and "bound column".

Regards

Jeff Boyce
Microsoft Office/Access MVP

Zedbiker said:
See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

:

Delimiters surround a value. For example, you use quotes to surround
text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the "#"
...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

:

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the
input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of
your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying
data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be
that
you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not
treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However
when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't
find
the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
Z

Zedbiker

OK thanks I didn't know that but unfortunately it still hasn't solved the
problem.

Thanks you all for your patience.

Ian

Douglas J. Steele said:
You can only use Like with text fields.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Zedbiker said:
SELECT DISTINCT Logtable.DateReported
FROM Logtable
WHERE (((Logtable.DateReported) Is Not Null And (Logtable.DateReported)
Like
"*" & [Enter Search Details or "*":] & "*"))
ORDER BY Logtable.DateReported DESC;

Column Count = 1
Column Width = 2.554cm

I am sorry if I misunderstood. Should I have used "#" here instead of "*"

Regards
Ian

Jeff Boyce said:
I don't know what you are using to "fill" the CmbDate combobox. Please
post
the SQL of the RowSource, indicate column widths and "bound column".

Regards

Jeff Boyce
Microsoft Office/Access MVP

See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

:

Delimiters surround a value. For example, you use quotes to surround
text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the "#"
...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

:

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the
input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part of
your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the underlying
data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may be
that
you
actually have a Date/Time value, but you are trying to find the
"formatted"
version. Or you may be using a selection criterion but not
treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

I am trying to filter records by searching for a date. However
when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't
find
the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
D

Douglas J. Steele

What does 01/10/2006 mean to you: 1 Oct, 2006 or 10 Jan, 2006? To Access, it
ALWAYS means 10 Jan, 2006, regardless of what your Short Date format has
been set to through Regional Settings. 11/10/2006 would also be interpretted
incorrectly, though, although 13/10/2006 and on would be fine.

If that's the issue, check what Allen Browne has at
http://www.allenbrowne.com/ser-36.html and/or what I had in my September,
2003 "Access Answers" column in Pinnacle Publication's "Smart Access". (You
can download the column and sample database from
http://www.accessmvp.com/djsteele/smartaccess.html)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Zedbiker said:
OK thanks I didn't know that but unfortunately it still hasn't solved the
problem.

Thanks you all for your patience.

Ian

Douglas J. Steele said:
You can only use Like with text fields.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Zedbiker said:
SELECT DISTINCT Logtable.DateReported
FROM Logtable
WHERE (((Logtable.DateReported) Is Not Null And (Logtable.DateReported)
Like
"*" & [Enter Search Details or "*":] & "*"))
ORDER BY Logtable.DateReported DESC;

Column Count = 1
Column Width = 2.554cm

I am sorry if I misunderstood. Should I have used "#" here instead of
"*"

Regards
Ian

:

I don't know what you are using to "fill" the CmbDate combobox.
Please
post
the SQL of the RowSource, indicate column widths and "bound column".

Regards

Jeff Boyce
Microsoft Office/Access MVP

See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a
forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

:

Delimiters surround a value. For example, you use quotes to
surround
text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the
"#"
...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

:

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the
input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part
of
your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the
underlying
data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may
be
that
you
actually have a Date/Time value, but you are trying to find
the
"formatted"
version. Or you may be using a selection criterion but not
treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

message
I am trying to filter records by searching for a date.
However
when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't
find
the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
Z

Zedbiker

That explains a lot. To me it means 1 Oct, 2006. I will check out those
links.

Many thanks again to you and Jeff Boyce for your patience and assistance.

Regards

Ian

Douglas J. Steele said:
What does 01/10/2006 mean to you: 1 Oct, 2006 or 10 Jan, 2006? To Access, it
ALWAYS means 10 Jan, 2006, regardless of what your Short Date format has
been set to through Regional Settings. 11/10/2006 would also be interpretted
incorrectly, though, although 13/10/2006 and on would be fine.

If that's the issue, check what Allen Browne has at
http://www.allenbrowne.com/ser-36.html and/or what I had in my September,
2003 "Access Answers" column in Pinnacle Publication's "Smart Access". (You
can download the column and sample database from
http://www.accessmvp.com/djsteele/smartaccess.html)



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Zedbiker said:
OK thanks I didn't know that but unfortunately it still hasn't solved the
problem.

Thanks you all for your patience.

Ian

Douglas J. Steele said:
You can only use Like with text fields.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


SELECT DISTINCT Logtable.DateReported
FROM Logtable
WHERE (((Logtable.DateReported) Is Not Null And (Logtable.DateReported)
Like
"*" & [Enter Search Details or "*":] & "*"))
ORDER BY Logtable.DateReported DESC;

Column Count = 1
Column Width = 2.554cm

I am sorry if I misunderstood. Should I have used "#" here instead of
"*"

Regards
Ian

:

I don't know what you are using to "fill" the CmbDate combobox.
Please
post
the SQL of the RowSource, indicate column widths and "bound column".

Regards

Jeff Boyce
Microsoft Office/Access MVP

See the two lines of code showing how I delimit the date.
This has been taken from suggested code from another query on a
forum.

rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"

Thanks again.

Ian

:

Delimiters surround a value. For example, you use quotes to
surround
text
.... "This is text".

The delimiter Access recognizes as surrounding a date value is the
"#"
...
#1/1/2007# will be recognized as a date.

Regards

Jeff Boyce
Microsoft Office/Access MVP

No I am using "0". Should I be using ##/##/####?

Thanks for your patience.
Ian

:

Are you using "#" as a delimiter?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Thanks for your reply.

The data type is Date/Time, formatted as short date, with the
input
mask "
00/00/0000;0;0_ ". Not quite sure I understand the last part
of
your
reply.

Thanks again.

Ian

:

It all starts with the data...

You are calling "01/10/2006" a "date". What is the
underlying
data
type
of
the field in which this "value" is stored?

How you select/search will depend on what is stored. It may
be
that
you
actually have a Date/Time value, but you are trying to find
the
"formatted"
version. Or you may be using a selection criterion but not
treating
it
as a
date (i.e., using the "#" delimiters).

Regards

Jeff Boyce
Microsoft Office/Access MVP

message
I am trying to filter records by searching for a date.
However
when
the
date
starts with a zero eg. 01/10/2006 for some reason it can't
find
the
date.
It
will find any other date with no problem. eg. 11/10/2006
Below is the code I am using.
Many thanks in advance for any help .

Private Sub CmbDate_AfterUpdate()

Dim rs As Object
Dim stDocName As String
Dim stLinkCriteria

stDocName = "Fault Log"
DoCmd.ShowAllRecords
Set rs = Me.Recordset.Clone
rs.FindFirst "[DateReported] = #" & Me.CmbDate & "#"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
stLinkCriteria = "[DateReported]= #" & Me.CmbDate & "#"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

***************************
 
J

JEA

I've just written a post about this, I know how infuriating this is as I had
EXACTLY the same problem. The majority of people I asked were from USA so
didn't understand the problem (not their fault before you label me as
xenophobic).
Anyway, take a look at this:
http://www.accessmonster.com/Uwe/Forum.aspx/access-modulesdaovba/27652/Fields-by-date


That explains a lot. To me it means 1 Oct, 2006. I will check out those
links.

Many thanks again to you and Jeff Boyce for your patience and assistance.

Regards

Ian
What does 01/10/2006 mean to you: 1 Oct, 2006 or 10 Jan, 2006? To Access, it
ALWAYS means 10 Jan, 2006, regardless of what your Short Date format has
[quoted text clipped - 153 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top