filter on dates

  • Thread starter Thread starter Ticotion
  • Start date Start date
T

Ticotion

Hi

I have a problem filtering a form on dates. I use the following code which
is activated when a user push a botton

Private Sub Kommandoknap148_Click()

If IsNull(Me.Kombinationsboks144) Then
' check if the user has entered a department
MsgBox "Vælg en Produktionslinje"

Else

Me.Filter = "[Prodlinje] = '" & Me.Kombinationsboks144 & "' And [Datem]=#" &
Me.Kombinationsboks136 & "#"

Me.FilterOn = True

End If

End Sub

When it filters my form it reverse the date syntaks (it is dd-mm-yyyy) and
it finds records that have yyyy-mm-dd. How do I solve this problem?

Help please

Ticotion
 
Specify the formatting so that it matches what JET expects, i.e.:

Me.Filter = "[Prodlinje] = '" & Me.Kombinationsboks144 & _
"' And [Datem]=#" & Format(Me.Kombinationsboks136, "mm\/dd\/yyyy") & "#"

Do not change the expression above to match your local date settings. More
info in this article:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html
 
Thank you that worked


Allen Browne said:
Specify the formatting so that it matches what JET expects, i.e.:

Me.Filter = "[Prodlinje] = '" & Me.Kombinationsboks144 & _
"' And [Datem]=#" & Format(Me.Kombinationsboks136, "mm\/dd\/yyyy") & "#"

Do not change the expression above to match your local date settings. More
info in this article:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Ticotion said:
Hi

I have a problem filtering a form on dates. I use the following code which
is activated when a user push a botton

Private Sub Kommandoknap148_Click()

If IsNull(Me.Kombinationsboks144) Then
' check if the user has entered a department
MsgBox "Vælg en Produktionslinje"

Else

Me.Filter = "[Prodlinje] = '" & Me.Kombinationsboks144 & "' And [Datem]=#"
&
Me.Kombinationsboks136 & "#"

Me.FilterOn = True

End If

End Sub

When it filters my form it reverse the date syntaks (it is dd-mm-yyyy) and
it finds records that have yyyy-mm-dd. How do I solve this problem?

Help please

Ticotion
 
Back
Top