Results 1 to 4 of 4
  1. #1
    raynman1972 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    31

    Question about using MysQL Code (LEFT, RIGHT, LENGTH, MAKETIME) in ACCESS VBA

    Hello all,

    I have the following piece of a query that is causing a Run-time error'3075', Syntax error (missing operator) in query expression. The query works directly in Access as a Pass Through and it works in MySQL Query Browser, but it won't in VBA for some reason and I suspect that it is one of the MySQL Functions (LEFT, RIGHT, LENGTH, MAKETIME or TIMESTAMP) that is really causing the error. Can anybody else confirm or deny?


    Code:
    strSQLa = " SELECT dps.ACDLITE_NAME,cca.SHORTNAME AS SITE " _
        & " ,(CASE WHEN LENGTH(dps.TIME) = 4 THEN TIMESTAMP(ddps.STATISTIC_DATE, MAKETIME(LEFT(dps.TIME,2),RIGHT(dps.TIME,2),0)) " _
        & " WHEN LENGTH(dps.TIME) = 3 THEN TIMESTAMP(ddps.STATISTIC_DATE, MAKETIME(LEFT(dps.TIME,1),RIGHT(dps.TIME,2),0)) " _
        & " WHEN LENGTH(dps.TIME) = 2 THEN TIMESTAMP(ddps.STATISTIC_DATE, MAKETIME(0,RIGHT(dps.TIME,2),0)) " _
        & " WHEN LENGTH(dps.TIME) = 1 THEN TIMESTAMP(ddps.STATISTIC_DATE, MAKETIME(0,0,0)) END) AS ACT_DATETIME " & vbNewLine

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    The function MAKETIME is not a vba function. Pass through works because pass-thru is in the
    native syntax of the "other " database.

    Pass-thru to Oracle uses Oracle syntax etc.

  3. #3
    raynman1972 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    31
    Quote Originally Posted by orange View Post
    The function MAKETIME is not a vba function. Pass through works because pass-thru is in the
    native syntax of the "other " database.

    Pass-thru to Oracle uses Oracle syntax etc.
    Is there a workaround that you can suggest? Basically, I am hitting a MySQL db via a passthrough in my VBA code and I need to convert the time column I am getting from "1800" to "18:00".

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    My thought is for you to run your Pass thru MySQL query and then work with the returned data with Access and vba.
    I haven't worked with Pass throughs for a few years, but I did a lot of work against a corporate Oracle database from Acc2003.
    We would run the pass through query (Oracle SQL syntax) and then process the returned data in Access. I'm sure I've forgotten many of the details, but that was the gist of it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-25-2011, 11:16 AM
  2. MySQL & Access
    By Scorpio11 in forum Database Design
    Replies: 3
    Last Post: 05-21-2011, 02:32 PM
  3. Replies: 3
    Last Post: 02-02-2011, 01:00 PM
  4. Replies: 1
    Last Post: 03-09-2010, 10:23 AM
  5. VBA Code To Work With MySQL
    By botts121 in forum Programming
    Replies: 0
    Last Post: 07-08-2009, 08:51 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums