Extremely strange '2001' error

aywho

New member
Local time
Yesterday, 19:38
Joined
Jul 14, 2004
Messages
6
Hi,

I have a search form with some combo boxes and textboxes. Whenever I finish a search, clear the combo box, textboxes by clicking the 'CLEAR' button, and do a search again, it always gives me the '2001' error message. However, if I don't touch the 'CLEAR' button and keep doing my search by 'backspacing' the text in the textbox or re-selecting a new item in the combo box, then it will work fine. I'm not sure if there's somthing wrong with my queries...or is the way I program my 'Clear' button wrong?

error 2001 happens when:
1) do the search
2) push the 'Clear' button
3) do another search
4) error pops up!

no error when:
1) do the search
2) 'backspace' the text in textboxes, re-selecting another item in the combo box
3) do another search
4) No error!

Thanks a lot for your help.

Code:
Private Sub Search_Click()
 If docList.ListIndex = 0 Then
        If Me.dateEntry.Value <> 0 And Me.clientList.Value <> "" Then
            resultForm.Form.RecordSource = "qryAgreement_all"
        Else
            resultForm.Form.RecordSource = "qryAgreement"
        End If
more......

Code:
Private Sub Clear_Click()
    
    docList.Value = Null 
    
    refEntry.Value = ""
    dateEntry.Value = ""
    acctList.Value = Null
    productList.Value = Null
    clientList.Value = Null
    materialList.Value = Null
    bankList.Value = Null
    
    dateEntry.Enabled = False
    refEntry.Enabled = False
    bankList.Enabled = False
    acctList.Enabled = False
    productList.Enabled = False
    clientList.Enabled = False
    materialList.Enabled = False
    
End Sub
 
so it's the second call to your search routine that raises the error? or does the error occur during the call to your clear routine? can you post the entire search routine?

have you been able to identify which statement is producing the error? (if not, try stepping through the code or using MsgBox or Debug.Print to try to isolate the statement that is causing the error.)

the one thing that jumps out at me so far is that Null (which is what your clear routine sets many of the fields to) is not the same as an empty string (which is what you would have in a field if you backspaced). a lot of boolean tests will fail when you try to test a null value (in if statements and such), so if you have a lot of that in your search routine i would start looking there...
 

Users who are viewing this thread

Back
Top Bottom