|
Run time Error
#36961334
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
Ссылка на профиль пользователя:
|
|
|
|
Добрый день! Помогите пожалуйста в одном вопросе. У меня есть один отчет в Excel с макросом. Мне сказали внести в него изменения, добавить несколько строк. Я добавила, внесла изменения в коде макроса, запустила. Но вот макрос дал ошибку. run-time error '-2147217900(80040e14)': ora-00905 Отсутствует ключевое поле.
Я вот только ссылку на ячейку изменила с Cells(42, 4) на Cells(44, 4) и еще в цикле For j = 15 To с 32 на 34. В чем ошибка?
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61.
Dim j As Integer
For j = 15 To 32
Dim rs1 As ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs1.ActiveConnection = con
If Cells(j, 2 ).Value = "1" Then
Sql = " select"
Sql = Sql & " d.count_peredano_do_19"
Sql = Sql & " from irina.dealer_do_posle_19may d"
Sql = Sql & " where d.month_period like '" + Cells( 3 , 1 ).Text + "'"
Sql = Sql & " and d.delr_id = " + d + ""
Sql = Sql & " and d.rtpl_rtpl_id = " + Cells(j, 3 ).Text + ""
End If
If Cells(j, 2 ).Value = "2" Then
Sql = " select"
Sql = Sql & " d.count_peredano_posle_19"
Sql = Sql & " from irina.dealer_do_posle_19may d"
Sql = Sql & " where d.month_period like '" + Cells( 3 , 1 ).Text + "'"
Sql = Sql & " and d.delr_id = " + d + ""
Sql = Sql & " and d.rtpl_rtpl_id = " + Cells(j, 3 ).Text + ""
End If
rs1.Open Sql, con
Sheets("Лист1").Select
Cells(j, 5 ).Value = ""
Cells(j, 5 ).CopyFromRecordset rs1
If Cells(j, 5 ).Value = "" Then
Cells(j, 5 ).Value = "0"
End If
Next j
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset
Set rs2.ActiveConnection = con
Sql = " select"
Sql = Sql & " count(t.subs_id),"
Sql = Sql & " sum(t.vozn_30),"
Sql = Sql & " sum(t.vozn_40),"
Sql = Sql & " sum(case when t.vozn_50 >= 13/" + kd + " then 13/" + kd + " else t.vozn_50 end)"
Sql = Sql & " from ro.dealer_vozn_2 t"
Sql = Sql & " where t.delr_id = " + d + ""
Sql = Sql & " and t.activation_date >= to_date('" + Cells( 1 , 1 ).Text + "', 'dd.mm.yyyy')"
Sql = Sql & " and t.activation_date < to_date('" + Cells( 2 , 1 ).Text + "', 'dd.mm.yyyy')+1"
rs2.Open Sql, con
Cells( 44 , 4 ).Value = rs2.Fields( 0 ).Value
Cells( 44 , 5 ).Value = rs2.Fields( 1 ).Value
Cells( 44 , 6 ).Value = rs2.Fields( 2 ).Value
Cells( 44 , 7 ).Value = rs2.Fields( 3 ).Value
'Cells(34, 7).CopyFromRecordset rs1
If Cells( 44 , 5 ).Value = "" Then
Cells( 44 , 5 ).Value = "0"
End If
If Cells( 44 , 6 ).Value = "" Then
Cells( 44 , 6 ).Value = "0"
End If
If Cells( 44 , 7 ).Value = "" Then
Cells( 44 , 7 ).Value = "0"
End If
|
|
|