How to create montly report in excel using sql database in visual basic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meha
    New Member
    • Sep 2010
    • 1

    #1

    How to create montly report in excel using sql database in visual basic

    my sql datbase base in this format--
    id of employee,, name of employee,, daily date,, and status= absent or present or weekly off(wo)

    ---------------------------------------------------------
    id employee_name date status
    1 puja 12/09/2010 A
    1 puja 13/09/2010 A
    1 puja 14/09/2010 wo
    1 puja 15/09/2010 P
    2 poonam 12/09/2010 P
    2 poonam 13/09/2010 P
    2 poonam 14/09/2010 wo
    2 poonam 15/09/2010 A
    and so on
    --------------------------------------------------------


    and in vb form two dtpicker to select date in between i want to check report


    now i want to creat excel file in this format
    suppose i select data 12/09/2010 to `14/09/2010 now wnt too see all records in between this date
    in this format
    --------------------------------------------------------
    id employee_name 12/09 13/09 14/09
    1 puja A A wo
    2 poonam P P wo
    -------------------------------------------------------




    plz help
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    That would be a start:
    Code:
    Function serialize()
        Dim rs As New ADODB.Recordset
        Dim cn As New ADODB.Connection
        Dim sql As String
        Dim aNames As Variant
        Dim thisName As Variant
        Set cn = CurrentProject.Connection
        sql = "SELECT DISTINCT lastName from myTable"
        rs.Open sql, cn
        aNames = rs.GetRows
        rs.Close
        For Each thisName In aNames
            sql = "SELECT status from MyTable" & _
            " WHERE date>= #2010-04-20# AND date<= #2010-04-28#" & _
            " AND lastname='" & thisName & "'"
            rs.Open sql, cn
            s = Replace(rs.GetString, Chr(13), " ")
            Debug.Print thisName & " " & s
        Next thisName
        rs.Close
        Set cn = Nothing
        Set rs = Nothing
    End Function

    Comment

    Working...