From: Ticotion on
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?
From: Jeanette Cunningham on
# 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" <Ticotion(a)discussions.microsoft.com> wrote in message
news:34B4644E-4972-49D5-B0EB-FDDDA305FD05(a)microsoft.com...
> 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?


From: Ticotion on
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" wrote:

> # 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" <Ticotion(a)discussions.microsoft.com> wrote in message
> news:34B4644E-4972-49D5-B0EB-FDDDA305FD05(a)microsoft.com...
> > 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?
>
>
> .
>
From: Ticotion on
Sorry. I see it works on the subforms too.

Thank you for all your help

Ticotion

"Ticotion" wrote:

> 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" wrote:
>
> > # 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" <Ticotion(a)discussions.microsoft.com> wrote in message
> > news:34B4644E-4972-49D5-B0EB-FDDDA305FD05(a)microsoft.com...
> > > 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?
> >
> >
> > .
> >