loading multiple tables values from access to excel into single sheet using vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vishal anand
    New Member
    • Sep 2013
    • 7

    loading multiple tables values from access to excel into single sheet using vb6

    hi my name is vishal
    i am using vb6 as front-end and ms access as back-end. I dont want to use data report instead i want to export these multiple table values to excel.
    i have tried a code given below:
    Code:
    Option Explicit
    Dim dIsVisible As Boolean
    Dim inst As String
    Dim adoDatabase As ADODB.Connection
    Dim oRs As ADODB.Recordset
    
    
    
    Sub getDialyzerInfo()
        Me.Caption = "Dialyzer Info"
        fmeDialyzerID.Visible = True
        fmePatientwise.Visible = False
        dIsVisible = True
    End Sub
    
    Private Sub cmdGenerate_Click()
    Dim xlApp As Excel.Application
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim var As Variant
    
    Set xlApp = New Excel.Application
    Set wb = xlApp.Workbooks.Open("D:\Workarea\vishal\130918\dialyser.xls.xlsx")
    Set ws = wb.Worksheets("Sheet1")
    Me.Hide
    Dim adoDatabase As New ADODB.Connection
    Dim oRs As New ADODB.Recordset
    If (dIsVisible = True) Then
            If (Trim(Text1.Text) <> "") Then
    adoDatabase.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
                             "Dbq=tuscanDB.mdb;" & _
                             "DefaultDir=" & App.Path & ";" & _
                             "Uid=Admin;Pwd=;"
    adoDatabase.Open
     oRs = adoDatabase.Execute("select r.dialysis_date,pn.patient_first_name,pn.patient_last_name, d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.technician_first_name,t.technician_last_name from dialyser d,patient_name pn, reprocessor r, techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and t.technician_id=r.technician_id and d.deleted_status=false and pn.status=true and d.dialyserID=('" & Text1.Text & "') order by r.dialysis_date desc,pn.patient_first_name,pn.patient_last_name", "DCS Clinical Report-For Dialyzer ID(" & Text1.Text & ")")
    End If
    Else
            If cboPatientID.ListIndex = 0 Then
                Set oRs = adoDatabase.Execute("select r.dialysis_date,pn.patient_first_name,pn.patient_last_name, d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.technician_first_name,t.technician_last_name from dialyser d,patient_name pn, reprocessor r, techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and r.dialysis_date between cdate('" & dtFrom.Value & "') and cdate('" & dtTo.Value & "') and t.technician_id=r.technician_id and d.deleted_status=false and pn.status=true order by r.dialysis_date desc,pn.patient_first_name,pn.patient_last_name", "DCS Clinical Report - Patient wise")
            Else
            Set oRs = adoDatabase.Execute("select r.dialysis_date,pn.patient_first_name,pn.patient_last_name, d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.technician_first_name,t.technician_last_name from dialyser d,patient_name pn, reprocessor r, techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and r.dialysis_date between cdate('" & dtFrom.Value & "') and cdate('" & dtTo.Value & "') and d.patient_id=" & Left(cboPatientID.List(cboPatientID.ListIndex), InStr(cboPatientID.List(cboPatientID.ListIndex), "|") - 1) & " and t.technician_id=r.technician_id and d.deleted_status=false and pn.status=true order by r.dialysis_date desc,pn.patient_first_name,pn.patient_last_name", "DCS Clinical Report - Patient wise")
            End If
            End If
        Unload Me
    End Sub
    but i get error(run-time)"Invalid procedure call or argument"
    Can anyone help me please?
    Last edited by Rabbit; Sep 19 '13, 03:24 PM. Reason: Please use code tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    On which line of code do you get the error?

    Comment

    Working...