Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


RUN-TIME ERROR '1004' General OBDC Errror


RUN-TIME ERROR '1004' General OBDC Errror

Author
Message
gencom99
gencom99
Forum God
Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)

Group: Forum Members
Posts: 4, Visits: 11
  1. Private Sub CommandButton1_Click()
  2. Dim NumList As String
  3. Dim SourceBook As Workbook
  4. Dim ListSheet As Worksheet
  5. Dim QuerySheet As Worksheet
  6. Dim Query As QueryTable
  7. Dim Numb As String
  8.  
  9. Set SourceBook = Application.ActiveWorkbook
  10. Set ListSheet = SourceBook.Worksheets("Main")
  11. Set QuerySheet = SourceBook.Worksheets("MONEY")
  12. Numb = Range("H6")
  13.  
  14. If ListSheet.Cells(6, 8).Value = "" Then Exit Sub
  15. NumList = "'" & ListSheet.Cells(6, 8).Value & "'"
  16.  
  17. Set Query = QuerySheet.QueryTables("MNY")
  18. Query.Sql = "SELECT NUMB_TBLE.NUMB_NAME, TO_CHAR(NUMB_DATES_TBLE.DAY_MTH_YR, 'MONTH'),  TO_CHAR(NUMB_DATES_TBLE.DAY_MTH_YR, 'YYYY'), SUM(NUMB_TBLE. PAY_IN), SUM(NUMB_TBLE. PAY_OUT),  SUM(NUMB_TBLE. NET_PAY)  "_
  19. & "FROM JES.NUMB TBLE NUMB TBLE,
  20. JES.NUMB_DATES_TBLE NUMB_DATES_TBLE" _
  21. & "WHERE NUMB_TBLE.NUMB_ID = NUMB_DATES_TBLE.NUMB_ID AND NUMB_TBLE.NUMB_CODE IN (" & NumList & ") " _
  22. & "Group by numb_tble.numb_name,  TO_CHAR(NUMB_DATES_TBLE.DAY_MTH_YR, 'YYYY'), TO_CHAR(NUMB_DATES_TBLE.DAY_MTH_YR, 'MONTH')
  23. Query.Refresh (False)
  24. End Sub

 

When I add SUM(NUMB_TBLE. NET_PAY) to the code, I receive General ODBC error.

Before I add this code, the query works.

What is going on?

How do I fix it?

 

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search