Filter causes Access to close

G

Guest

Running Win2k & A97 +all updates and Jet5.31sp3.
The following code is executed when double clicked in a text field.
It opens a new form, filtered to the proper field.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Query by Part Number"

stLinkCriteria = "[Part Number]=" & "'" & Me![Part Number] & "'"
DoCmd.OpenForm stDocName, , stLinkCriteria
Forms![Query by Part Number].Filter = stLinkCriteria
Forms![Query by Part Number].FilterOn = True

The problem is, when I click the 'filter' button on the toolbar to then
'unfilter' the open form, Access closes with a simple message.

Program Error
"msaccess.exe has generated errors and will be closed by windows. You will
need to restart the program.
An error log is being created."

I receive this on other occassions, but this is one I can repeat.
I also just re-loaded Access - same results.
Any suggestions?
 
P

Pieter Wijnen

Why do you open the Form with a (attempted) WhereClause & set the filter to
the same in the form?

DoCmd.OpenForm stDocName, WhereClause:=stLinkCriteria
should suffice

Pieter
 
G

Guest

Originally I had just the one line, as you suggested, and had this problem
(as mentioned below). I then added the filter lines because I wasnt sure if
the WhereClause performed like a filter or not. And by hitting the unfilter
button, would it remove the filter. I removed these two lines again and
still have the same error appear.
Any other thoughts?


Pieter Wijnen said:
Why do you open the Form with a (attempted) WhereClause & set the filter to
the same in the form?

DoCmd.OpenForm stDocName, WhereClause:=stLinkCriteria
should suffice

Pieter

good12find said:
Running Win2k & A97 +all updates and Jet5.31sp3.
The following code is executed when double clicked in a text field.
It opens a new form, filtered to the proper field.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Query by Part Number"

stLinkCriteria = "[Part Number]=" & "'" & Me![Part Number] & "'"
DoCmd.OpenForm stDocName, , stLinkCriteria
Forms![Query by Part Number].Filter = stLinkCriteria
Forms![Query by Part Number].FilterOn = True

The problem is, when I click the 'filter' button on the toolbar to then
'unfilter' the open form, Access closes with a simple message.

Program Error
"msaccess.exe has generated errors and will be closed by windows. You
will
need to restart the program.
An error log is being created."

I receive this on other occassions, but this is one I can repeat.
I also just re-loaded Access - same results.
Any suggestions?
 
P

Pieter Wijnen

You might need to Open the Form w/o any Filter & set it up in the Load Event
DoCmd.OpenForm stDocName,OpenArgs = "[Part Number]=" & "'" & Me![Part
Number] & "'"

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.Filter = Me.OpenArgs
Me.FilterOn = True
End If
End Sub

HTH

Pieter

PS What version of Access are you running, can't say I've run into this
problem, but then I've stayed with Access '97 or Access2003 whenever
possible <g>

good12find said:
Originally I had just the one line, as you suggested, and had this problem
(as mentioned below). I then added the filter lines because I wasnt sure
if
the WhereClause performed like a filter or not. And by hitting the
unfilter
button, would it remove the filter. I removed these two lines again and
still have the same error appear.
Any other thoughts?


Pieter Wijnen said:
Why do you open the Form with a (attempted) WhereClause & set the filter
to
the same in the form?

DoCmd.OpenForm stDocName, WhereClause:=stLinkCriteria
should suffice

Pieter

good12find said:
Running Win2k & A97 +all updates and Jet5.31sp3.
The following code is executed when double clicked in a text field.
It opens a new form, filtered to the proper field.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Query by Part Number"

stLinkCriteria = "[Part Number]=" & "'" & Me![Part Number] & "'"
DoCmd.OpenForm stDocName, , stLinkCriteria
Forms![Query by Part Number].Filter = stLinkCriteria
Forms![Query by Part Number].FilterOn = True

The problem is, when I click the 'filter' button on the toolbar to then
'unfilter' the open form, Access closes with a simple message.

Program Error
"msaccess.exe has generated errors and will be closed by windows. You
will
need to restart the program.
An error log is being created."

I receive this on other occassions, but this is one I can repeat.
I also just re-loaded Access - same results.
Any suggestions?
 

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