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:
but i get error(run-time)"Invalid procedure call or argument"
Can anyone help me please?
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
Can anyone help me please?
Comment