Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

VB FindRecord crash if criteria not found

$
0
0
Hello,

I made a continuous form from a query with 2 comboBoxes to filter the query.

in the query the code of each column is:

Code:

Like "*" & [Forms]![Part_List_form]![Stat_Box_Select] & "*"
Code:

Like "*" & [Forms]![Part_List_form]![Cat_Box_Select] & "*"
for the combo boxes the code is:

Code:

Private Sub Cat_Box_Select_AfterUpdate()


    Me!Category.SetFocus
    If IsNull(Me!Cat_Box_Select.Value) Then
        Exit Sub
   
    Else:
    DoCmd.FindRecord (Me!Cat_Box_Select.Value)
    End If
   
    DoCmd.ShowAllRecords

and


Code:

Private Sub Stat_Box_Select_AfterUpdate()
   
    Me!Status.SetFocus
    If IsNull(Me!Stat_Box_Select.Value) Then
        Exit Sub
   
    Else:
   
    DoCmd.FindRecord (Me!Stat_Box_Select.Value)
    End If
   
    DoCmd.ShowAllRecords
   
End Sub

It all works fine. I can use both combobox to filter or just 1 and leave the other blank and it still works.

However when I use both and the criteria is not found, for example if a category doesn't have any records with that status, it will crash saying:
Run-Time Error "2137"
You can't use Find or replace now


anyone have any ideas on how to fix this.

Viewing all articles
Browse latest Browse all 13329

Trending Articles