Form filter problem

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?
 
J

Jeanette Cunningham

# 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
 
T

Ticotion

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?


.
 
T

Ticotion

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?


.
 

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
Chart problem 2 5
Filter Report based on forms filter 2
Split Form filter problem 4
Function for week number 5
Multiple Filter Criteria 4
Filter form recordset 1
Runtime error 2001 2

Top