filter on dates

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
 
A

Allen Browne

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
 
T

Ticotion

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
 

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

Filter syntax problems 2
Report chart problem 2
Form filter on date 5
Forcing a date entry format of dd/mm/yyyy 1
FILTER DATES 4
Dates swapping 5
Filter Report based on forms filter 2
Australian dates in access 3

Top