access crash when changing form filter

给你一囗甜甜゛ 提交于 2019-12-12 22:43:41

问题


here's my form.

Access always crash if I do these steps:

  1. Do a search for the year 2012
  2. Then do a search for the proposal number 12-100 (which exists)

No matter what, if I do the year search then the search for the proposal number or vice versa. it will crash. By crash,I mean access stop working and has to restart.

They both work if I close the form before to do the second one.

Here's the code for my find and clear button (That's almost all the code of my form).

 Private Sub btnFind_Click()
    If (Not IsNull(txtResearch) And txtResearch <> "") Then
        Me.Filter = "ProposalNo = '" & txtResearch & "'"
        Me.FilterOn = True
    ElseIf (Not IsNull(txtYear) And txtYear <> "") Then
        Me.Filter = "pyear = " & txtYear
        Me.FilterOn = True
    Else
        Me.Filter = ""
        Me.FilterOn = False
    End If

End Sub



Private Sub btnClear_Click()
    txtResearch = ""
    txtYear = ""
    Me.Filter = ""
    Me.FilterOn = False
End Sub

The problem is it the way I set the filter? I wasn't sure about Me.FilterOn

Also, I did try to compact and repair but no luck

Thank you


回答1:


Apparently there may be a bit of a problem with filters and SQL Server, but I am not well enough up on the subject. You might also like to look at Allen Browne's notes here: http://www.pcreview.co.uk/forums/access-crashes-remove-filter-sub-form-t2772609.html

You may wish to consider setting the recordsource with a where statement rather than using filters.



来源:https://stackoverflow.com/questions/13088701/access-crash-when-changing-form-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!