Results 1 to 3 of 3

Thread: SQL and VB User Functions

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    SQL and VB User Functions

    User Function fails in an SQL Select statement within VB.

    User function works great with SQL Select statement within Access when User Function is included within an Access module.

    ANYONE KNOW HOW TO SOLVE THIS?

  2. #2
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Hi

    explain a little more. Normaly all SQl statements that are working in access hould be work in VB.

    Franky

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166
    Thanks for responding.

    FYI: In doing initial search before post JasonS had this problem a while back but saw no solution posted. Hence repost.
    He also has an example if you wish to review it.

    --------------

    The following SQL was created. WeekEnding is a User created functions. The SQL and function return the correct recordset in Access.

    In VB it executes but ZERO records are returned.

    So it appears there is some issue or special format necessary so Access can recognize the User Function when passed via an SQL string. BTW: I have included the User function both in Access and VB.



    '******
    'Create Query To Compress
    'Daily to Weekly Data
    '******
    strParm = "PARAMETERS [pBegDate] DateTime, [pEndDate] DateTime; "
    strSQL = strParm & "SELECT (WeekEnding([fldHistDateTime])) As DateOnly, " _
    & "First(fldHistOpen) AS OpenPrice, " _
    & "Max(fldHistHigh) AS HighPrice, " _
    & "Min(fldHistLow) AS LowPrice, " _
    & "Last(fldHistClose) AS ClosePrice " _
    & "FROM " & strSourceTBLName & " " _
    & "WHERE (((fldHistDateTime) Between [pBegDate] And [pEndDate])) " _
    & "GROUP BY (WeekEnding([fldHistDateTime]));"
    Last edited by dw85745; May 4th, 2002 at 11:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width