Link to home
Create AccountLog in
Avatar of Dare626
Dare626Flag for United States of America

asked on

Export Access VBA function Output/Results To Excel File

Private Sub GetNonCaptures()
    Dim rst11 As DAO.Recordset
    Dim rst12 As DAO.Recordset
    Dim fld As Field
    Dim strNonCapture
    
    Set rst11 = CurrentDb.OpenRecordset("AllCareP_Result_2011-1")
    Set rst12 = CurrentDb.OpenRecordset("Select * From AllCareP_Accept_2012-1")
    
    Do While Not rst11.EOF
        strNonCapture = ""
        For Each fld In rst11.Fields
            If fld.Name Like "HCC_CD*" And fld.Value = "YES" Then
                      rst12.FindFirst "[MEM_NO]='" & rst11!MEM_NO & "' AND [HCC_CD]='" & Mid(fld.Name, 7) & "'"
                If rst12.NoMatch Then
                    strNonCapture = strNonCapture & ", " & fld.Name
                End If
            End If
        Next
        strNonCapture = Mid(strNonCapture, 3)
        If strNonCapture <> "" Then
            Debug.Print "MEMBER " & rst11!MEM_NO & " DID NOT HAVE " & strNonCapture & " CAPTURED IN 2012"
            End If
        rst11.MoveNext
    Loop
    
End Sub

Open in new window

I have this code below which outputs to the immediate window id like to export the results of this to an excel file or txt file named "HCC_Bucket_Resuls" can someone modify the output string please.

Debut.print etc. Thank you much.[
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Dare626

ASKER

Thank you IrogSinta, I appreciate it.