423,688 Members | 1,894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

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

P: 7
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:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim dIsVisible As Boolean
  3. Dim inst As String
  4. Dim adoDatabase As ADODB.Connection
  5. Dim oRs As ADODB.Recordset
  6.  
  7.  
  8.  
  9. Sub getDialyzerInfo()
  10.     Me.Caption = "Dialyzer Info"
  11.     fmeDialyzerID.Visible = True
  12.     fmePatientwise.Visible = False
  13.     dIsVisible = True
  14. End Sub
  15.  
  16. Private Sub cmdGenerate_Click()
  17. Dim xlApp As Excel.Application
  18. Dim wb As Workbook
  19. Dim ws As Worksheet
  20. Dim var As Variant
  21.  
  22. Set xlApp = New Excel.Application
  23. Set wb = xlApp.Workbooks.Open("D:\Workarea\vishal\130918\dialyser.xls.xlsx")
  24. Set ws = wb.Worksheets("Sheet1")
  25. Me.Hide
  26. Dim adoDatabase As New ADODB.Connection
  27. Dim oRs As New ADODB.Recordset
  28. If (dIsVisible = True) Then
  29.         If (Trim(Text1.Text) <> "") Then
  30. adoDatabase.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
  31.                          "Dbq=tuscanDB.mdb;" & _
  32.                          "DefaultDir=" & App.Path & ";" & _
  33.                          "Uid=Admin;Pwd=;"
  34. adoDatabase.Open
  35.  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 & ")")
  36. End If
  37. Else
  38.         If cboPatientID.ListIndex = 0 Then
  39.             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")
  40.         Else
  41.         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")
  42.         End If
  43.         End If
  44.     Unload Me
  45. End Sub
but i get error(run-time)"Invalid procedure call or argument"
Can anyone help me please?
Sep 19 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,272
On which line of code do you get the error?
Sep 19 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.