Run-time erroe '2001'

G

Guest

I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.


Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If

If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If

If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If

If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed] = """ & _
Me.cborescomplete & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

Thanks in advance
 
D

Dan Artuso

HI,
This may or may not be it but, do you know that you have to delimit dates with the # sign?

Dan Artuso, MVP
 
R

Raj

Dan,
No, I did not know what, I am still learning.. Could you
give me some help on where I would put the #'s I look in
the Help, but I am not sure where I would place them in
the statement:

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "

-----Original Message-----
HI,
This may or may not be it but, do you know that you have
to delimit dates with the # sign?
Dan Artuso, MVP

I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.


Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If

If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If

If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If

If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed] = """ & _
Me.cborescomplete & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

Thanks in advance


.
 
D

Dan Artuso

Hi,
strWhere = strWhere & "([project_name] = #" & _
Me.cboproject & #") AND "

You were delimiting with double quotes ("") so you just replace those with #

HTH
Dan Artuso, MVP

Raj said:
Dan,
No, I did not know what, I am still learning.. Could you
give me some help on where I would put the #'s I look in
the Help, but I am not sure where I would place them in
the statement:

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "

-----Original Message-----
HI,
This may or may not be it but, do you know that you have
to delimit dates with the # sign?
Dan Artuso, MVP

I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.


Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If

If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If

If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If

If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed] = """ & _
Me.cborescomplete & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

Thanks in advance


.
 
R

Raj

Dan,
THANK YOU!!! It work perfect...
Raj
-----Original Message-----
Hi,
strWhere = strWhere & "([project_name] = #" & _
Me.cboproject & #") AND "

You were delimiting with double quotes ("") so you just replace those with #

HTH
Dan Artuso, MVP

"Raj" <[email protected]> wrote in
message news:[email protected]...
Dan,
No, I did not know what, I am still learning.. Could you
give me some help on where I would put the #'s I look in
the Help, but I am not sure where I would place them in
the statement:

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "

-----Original Message-----
HI,
This may or may not be it but, do you know that you
have
to delimit dates with the # sign?
Dan Artuso, MVP

I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.


Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If

If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If

If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If

If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed]
= """
& _
Me.cborescomplete & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

Thanks in advance



.


.
 
R

Raj

Dan,
I am having the same problems with a numeric field, I
used the # like witht the dates but I am getting and
error. How do I delimit a numeric field?Can you help me
out again.
Thank you Raj..
-----Original Message-----
Hi,
strWhere = strWhere & "([project_name] = #" & _
Me.cboproject & #") AND "

You were delimiting with double quotes ("") so you just replace those with #

HTH
Dan Artuso, MVP

"Raj" <[email protected]> wrote in
message news:[email protected]...
Dan,
No, I did not know what, I am still learning.. Could you
give me some help on where I would put the #'s I look in
the Help, but I am not sure where I would place them in
the statement:

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "

-----Original Message-----
HI,
This may or may not be it but, do you know that you
have
to delimit dates with the # sign?
Dan Artuso, MVP

I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is highlighted.


Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If

If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If

If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If

If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed]
= """
& _
Me.cborescomplete & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

Thanks in advance



.


.
 
D

Dan Artuso

Hi,
Numeric fields need no delimiters.

Dan Artuso, MVP

Raj said:
Dan,
I am having the same problems with a numeric field, I
used the # like witht the dates but I am getting and
error. How do I delimit a numeric field?Can you help me
out again.
Thank you Raj..
-----Original Message-----
Hi,
strWhere = strWhere & "([project_name] = #" & _
Me.cboproject & #") AND "

You were delimiting with double quotes ("") so you just replace those with #

HTH
Dan Artuso, MVP

"Raj" <[email protected]> wrote in
message news:[email protected]...
Dan,
No, I did not know what, I am still learning.. Could you
give me some help on where I would put the #'s I look in
the Help, but I am not sure where I would place them in
the statement:

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "


-----Original Message-----
HI,
This may or may not be it but, do you know that you have
to delimit dates with the # sign?

Dan Artuso, MVP

I am getting to my wits end with this problem and I am
hoping someone can help me, I really need this to work.
I am using this code to filter a form the first three
work great but when I try to use it on a date field I
keep getting "Run-time error '2001' You canceled the
previous operation". When I go to debug it
has "Me.Filter = (left(strWhere, LngLen) is
highlighted.


Dim strWhere As String
Dim lngLen As Long

If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

If Not IsNull(Me.cboproject) Then
strWhere = strWhere & "([project_name] = """ & _
Me.cboproject & """) AND "
End If

If Not IsNull(Me.cbocontact) Then
strWhere = strWhere & "([ratm_contact] = """ & _
Me.cbocontact & """) AND "
End If

If Not IsNull(Me.cbobusiness) Then
strWhere = strWhere & "([business_unit] = """ & _
Me.cbobusiness & """) AND "
End If

If Not IsNull(Me.cborescomplete) Then
strWhere = strWhere & "([research_completed] = """
& _
Me.cborescomplete & """) AND "
End If

'etc for other search boxes.

lngLen = Len(strWhere) - 5 'Without trailing "
AND ".
If lngLen <= 0 Then
MsgBox "No criteria."
Else

Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True

Thanks in advance



.


.
 

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

Top