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

Print results after search

Status
Not open for further replies.

GelC

Technical User
Oct 3, 2006
93
0
0
US
Hi all,
I have this code to perform my search.
I have a print button to print the results after searching.
Could someone please help?
Thanks in advanced.
Code:
Private Sub cmdSearch_Click()

Dim strWhere As String
Dim lngLen As Long

    If Not IsNull(Me.txtSongNumber) Then
        strWhere = strWhere & "([SongNumber] = Like ""*" & Me.txtSongNumber & "*"") AND "
    End If
    
    If Not IsNull(Me.txtTitle) Then
        strWhere = strWhere & "([Title] = Like ""*" & Me.txtTitle & "*"") AND "
    End If

    If Not IsNull(Me.txtAuthor) Then
        strWhere = strWhere & "([Author] = Like ""*" & Me.txtAuthor & "*"") AND "
    End If

    If Not IsNull(Me.txtKeywords) Then
        strWhere = strWhere & "([Keywords] = Like ""*" & Me.txtAuthor & "*"") AND "
    End If
    
    If Not IsNull(Me.txtYear) Then
        strWhere = strWhere & "([Year] = """ & Me.txtYear & """) AND "
    End If

    If Not IsNull(Me.cboArea) Then
        strWhere = strWhere & "([Area] = """ & Me.cboArea & """) AND "
    End If

    lngLen = Len(strWhere) - 5
    If lngLen <= 0 Then     'Nah: there was nothing in the string.
        MsgBox "Please enter at least a criteria", vbInformation, "Nothing to do."
    Else                    'Yep: there is something there, so remove the " AND " at the end.
        strWhere = Left$(strWhere, lngLen)
        
        'Finally, apply the string as the form's Filter.
        Me.Filter = strWhere
        Me.FilterOn = True
    End If
    
End Sub
 
I should have said that I want a print button to print the returned results. How do I implement this function? Could anybody help?
Thanks.
 
If you just want to view in the immediate window, put in debug.print strWhere.

Ever notice how fast Windows runs? Me neither.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top