error filtering subform with date

leanpilar

Registered User.
Local time
Today, 16:01
Joined
Aug 13, 2015
Messages
94
I'm feeling noob to ask a question about filtering because I did a lot of time but this time I can't find a way

the easy code
Dim StrDate As String
If Nz(Me.Text42.Value) = False Then
StrDate = "01." & Month(Date) & "." & Year(Date)
Else: StrDate = "01." & Me.Text42.Value & "." & Year(Date)
End If
Me.subform.Form.Filter = "[KAR_DATE]>= #" & CDate(StrDate) & "#"
Me.subform.Form.FilterOn = True

Run-time error 3075
syntax error in date in querry expression '([KAR:DATE]>=#1.8.2015#) AND ([__KAR_ID] = mainform.KAR_ID'.
without last ) and the field name is only KAR_ID and not __KAR_ID

any idea?
already try without CDate() and dim as date, add at the end & " And " & like I need for double filter
 
I haven't used '.' in dates before, I use '/' so don't know if that could be a problem. You shouldn't need CDate as you should have a string value between the #'s. Have you stopped the code on the Me.subform.Form.FilterOn = True to see what the Me.subform.Form.Filter contains?
 
thanks, I got I step forward.
I live in Croatia and they got the great idea to define date as dd.mm.yyyy. with . after yyyy and if I do CDate for 20/02/2015 I got 20.02.2015. but in code with / I got no more error filter on but the date field not filtered... Now I can continue working... thanks
 
Not working...
I try to make a query with new field where replace . to / and now the filter is working but not correctly...
if I filter date >= then 01/07/2015 it show the date where the day is higher then 07 and all month, and if I replace dd/mm to mm/dd it's not working at all...

any idea whato I can try??
 
I make it hard way :)
Cint( right 2 of left 5) and I got a number of the month
then filter Cint(month(date)) or Cint(text)
 

Users who are viewing this thread

Back
Top Bottom