Form filter problem

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

Ticotion

Hi

I have a main form where I have two subforms. I'm trying to filter all forms
by using the following code

'Assign filter to forms based on shift, sektor, cell and date
Me.Filter = "[Skiftnr] = #" & Me.Combo209 & "# And [Sektor] = #" & Me.Sektor
& "# And [Cellenr] = #" & Me.Combo144 & "# And [Dato]=#" &
Format(Me.Combo136, "mm\/dd\/yyyy") & "#"

Me.FilterOn = True

I get a syntax error saying "error in date in query expression '[Skift] =
#1# and [Sektor] = #1# and [Cellenr] = #1# and [Dato] = #11/18/2009'

I ca not see why there should be a problem with the date. Any suggestions?

The subforms are linked to the mainform via Skiftnr, Sektor, Cellenr and
Dato. Will the filter also Apply for them or would I need to make aditional
code?
 
# is only to be used with date fields/ controls.
If Skiftnr is a number, use " & Me.Combo209 & "
If Skiftnr is text, use """ & Me.Combo209 & """

Same thing for Sektor and Cellenr.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Hi Jeanette

Thank you pointing that out. I thing I have been staring me blind on the
error code.

One more question:

How do you apply the filter to subforms?

br
Ticotion

Jeanette Cunningham said:
# is only to be used with date fields/ controls.
If Skiftnr is a number, use " & Me.Combo209 & "
If Skiftnr is text, use """ & Me.Combo209 & """

Same thing for Sektor and Cellenr.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Ticotion said:
Hi

I have a main form where I have two subforms. I'm trying to filter all
forms
by using the following code

'Assign filter to forms based on shift, sektor, cell and date
Me.Filter = "[Skiftnr] = #" & Me.Combo209 & "# And [Sektor] = #" &
Me.Sektor
& "# And [Cellenr] = #" & Me.Combo144 & "# And [Dato]=#" &
Format(Me.Combo136, "mm\/dd\/yyyy") & "#"

Me.FilterOn = True

I get a syntax error saying "error in date in query expression '[Skift] =
#1# and [Sektor] = #1# and [Cellenr] = #1# and [Dato] = #11/18/2009'

I ca not see why there should be a problem with the date. Any suggestions?

The subforms are linked to the mainform via Skiftnr, Sektor, Cellenr and
Dato. Will the filter also Apply for them or would I need to make
aditional
code?


.
 
Sorry. I see it works on the subforms too.

Thank you for all your help

Ticotion

Ticotion said:
Hi Jeanette

Thank you pointing that out. I thing I have been staring me blind on the
error code.

One more question:

How do you apply the filter to subforms?

br
Ticotion

Jeanette Cunningham said:
# is only to be used with date fields/ controls.
If Skiftnr is a number, use " & Me.Combo209 & "
If Skiftnr is text, use """ & Me.Combo209 & """

Same thing for Sektor and Cellenr.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Ticotion said:
Hi

I have a main form where I have two subforms. I'm trying to filter all
forms
by using the following code

'Assign filter to forms based on shift, sektor, cell and date
Me.Filter = "[Skiftnr] = #" & Me.Combo209 & "# And [Sektor] = #" &
Me.Sektor
& "# And [Cellenr] = #" & Me.Combo144 & "# And [Dato]=#" &
Format(Me.Combo136, "mm\/dd\/yyyy") & "#"

Me.FilterOn = True

I get a syntax error saying "error in date in query expression '[Skift] =
#1# and [Sektor] = #1# and [Cellenr] = #1# and [Dato] = #11/18/2009'

I ca not see why there should be a problem with the date. Any suggestions?

The subforms are linked to the mainform via Skiftnr, Sektor, Cellenr and
Dato. Will the filter also Apply for them or would I need to make
aditional
code?


.
 
Back
Top