Attribute VB_Name = "utils"
Option Explicit

Public Const gLogFile As String = "FMSTest.log"

Public Function reportRecordSet(rs As Recordset) As String
If rs Is Nothing Then
    reportRecordSet = "RS IS NOTHING"
    Exit Function
End If
Dim rpt As String
Dim r As Long
Const rptstr = "%fld%[%r%]=%v%" '& vbCrLf
r = 1

rs.MoveFirst
Do While Not rs.EOF
    Dim fld As ADODB.Field
    For Each fld In rs.Fields
        rpt = rpt & rptstr & vbCrLf
        rpt = Replace(rpt, "%fld%", fld.Name)
        rpt = Replace(rpt, "%r%", r)
        If (fld.Type = adBoolean) Then
            rpt = Replace(rpt, "%v%", IIf(fld.Value, "True", "False"))
        ElseIf IsNumeric(fld.Value) Then
            rpt = Replace(rpt, "%v%", Format(fld.Value, "0.00"))
        Else
            rpt = Replace(rpt, "%v%", fld.Value)
        End If
    Next
    r = r + 1
    rs.MoveNext
Loop
reportRecordSet = rpt
End Function


Public Sub Main()
If Dir(gLogFile) <> "" Then Kill gLogFile

If Command = "/batch" Then
    frmFMSTest.cmdTest_Click
    End
Else
    frmFMSTest.Show
End If

End Sub
