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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter in datasheet view

Status
Not open for further replies.

hunterlpr

Technical User
Nov 15, 2002
15
US
I'm hoping someone can help me with this problem. I have a form that on an after update event filters the form and returns the records. I have coded this in visual basic and it works fine except that I want it to return the filtered records in datasheet view not in form view so that it will be easier to compare the records. After which ending the filter I want it to go back to the form view. And I want to use coding so that it's automatic. Thanks for any help.
 
Looked for a solution without much luck in VBA. How about displaying the data in a subform. After the filter use a form in DataSheet view. Without the filter use Single form view.
Code:
Private Sub txtFilter_AfterUpdate()    
    Dim StrSQL As String

    If Not IsNull(txtFilter) Then
        StrSQL = "SELECT INDIVIDUALS.*, INDIVIDUALS.Firstname " & _
                    "FROM INDIVIDUALS " & _
                    "WHERE (((INDIVIDUALS.Firstname) Like '" & Text26 & "*'));"
        Me.INDIVIDUALS.SourceObject = "INDIVIDUALSdatasheet"
        Me.INDIVIDUALS.Form.RecordSource = StrSQL
        
    Else
        Me.INDIVIDUALS.SourceObject = "INDIVIDUALSformview"
        Me.INDIVIDUALS.Form.RecordSource = "INDIVIDUALS"
        
    End If
End Sub

redapples
 
Thanks for taking the time to look it up for me and I appreciate the code. Nothing is ever as easy as one simple line. I was hoping just to put a domenuitem command in. I'll try the subform and code. Thanks for your help!
 
Whoops,

try
Code:
        Me.INDIVIDUALS.SetFocus
        DoCmd.RunCommand acCmdSubformDatasheet

plus some code needs to be there to enter the filter too.

never overlook the obvious I suppose. :)

hope you didn't spend too long on other stuff
 
Thanks again. Fortunately I got busy on another project and other coding dilemas so I didn't start the other coding. That looks like it will work....I'll give it try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top