Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Filter is Locking up DB

Status
Not open for further replies.

AmigoMobility

Technical User
May 8, 2005
57
0
0
US
A2K

I am using the code below to filter a subform[subCusDet] on MainForm
[frmCustomers], (using a pop up form). If records are found I allow the
subform to be filtered and this part works fine. If no records are found I am
trying to set the FilterOn back to false. At this point I'm getting an error
that the filter failed and then the db locks up. Any thoughts as to why? I
use this same code on other forms, except that it's filtering the form it's
on and not using a pop up form, and it works fine.

Also, while I'm at it. I seem to recall reading that filtering is not real
reliable and can cause goofy problems. Is that true? Should I be doing this
using recordsets instead?

Below is my code. Thanks for any help you can provide,
Shane

Dim stFilter As String
stFilter = "CreatedBy='" & Me.cboEnteredBy.Column(1) & "'"

Forms![frmCustomers]![subCusDet].Form.Filter = stFilter
Forms![frmCustomers]![subCusDet].Form.FilterOn = True
Forms![frmCustomers]![subCusDet].Form.Refresh
Dim stRCount As String
stRCount = Forms![frmCustomers]![subCusDet].Form.RecordsetClone.RecordCount

If stRCount <= 0 Then
Eval ("Msgbox('NO MATCHING PROGRESS NOTES!@The filter you chose did not
produce a match!. " & _
"The Progress Notes List will be reset Showing All Progress Notes@@',0,'Amigo
Message System')")
Forms![frmCustomers]![subCusDet].Form.FilterOn = False
Forms![frmCustomers]![subCusDet].Form.Requery
End If
 
I use the following code. Works ok. Maybe you can use it.

'return an error message if no records are found
Code:
    If Me.Recordset.RecordCount = 0 Then
        MsgBox "Sorry, no Bills Of Lading found for this Voyage"
        Me.Undo
        Me.FilterOn = False
    End If

Pampers [afro]
Just let it go...
 
Hey Pampers,

Thanks for your reply. I do the same thing you have recommended, on several other forms with no subform, but this is acting different from that. I have some investigating to do on the subforms properties. I have learned that a few events in the wrong place can cause a problem.

Thanks again for lending a hand,
Shane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top