Results 1 to 4 of 4

Thread: ACCESS: How To: Create Table from Pass-Through Query [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Resolved ACCESS: How To: Create Table from Pass-Through Query [RESOLVED]

    Esteemed Forum Participants and Lurkers:
    ===============================
    MS Access, remote Oracle Database NEWBIE ALERT!

    I am trying to create a table based on a one-time Pass-Through query snapshot of an Oracle database. I have made a lot of progress ... I can build static pass-through queries and I actually get real data back from my database! I have even had some luck and success with fetching date limited data using the Oracle SQL "TO_DATE" function.

    I have to generate my SQL statement dynamically ... the date range always changes ... so I have to load a table through code. Here is what I have so far:
    Code:
    Option Compare Database
    Option Explicit
    '=================================================================
    ' TEST ACCESS TO Oracle DER DATABASE
    '=================================================================
    Function Fetch_DER()
        Dim myDER As Database
        Dim myQuery As QueryDef
        Dim myTable As TableDef
        Dim strSQL1 As String
        
        ' Return reference to current database
        Set myDER = CurrentDb
        ' Connect to the Remote Oracle Data Base
        myDER.Connect = _
            "ODBC;DATABASE=DER_ACCESS;UID=myUID;PWD=password;DSN=DER_database_access"
        '===============================================================
        
        ' Delete the old table "TEST", if it exists
        If myDER.TableDefs.Count > 0 Then
            For Each myTable In myDER.TableDefs
                If myTable.Name = "TEST" Then
                    myDER.TableDefs.Delete myTable.Name
                End If
            Next
        End If
        
        ' Create a table from a dynamic pass-through query
        Set myTable = myDER.CreateTableDef("TEST")
        
        ' Define a simple test Pass-Through SQL statement
        strSQL1 = "SELECT * FROM [der.form_lim_view] WHERE prfl_id = 3940;"
        
        '  >>>> HERE IS WHERE I AM STUCK ...
        '                  I need to populate "TEST" from my pass-through query "strSQL1"
    
        MsgBox ("Look at the new 'TEST' Table!")
        
    End Function
    Do I need to create a 'temporary' QueryDef, or is there some easier way I can specify the SQL statement to pass to the "myDER" connection for loading the new table "TEST"? If I have to create a QueryDef, then I have to check for the old version, delete it if it exists, and then create a fresh version (yuk).

    My sincere appreciation for all comments, suggestions and assistance.
    Last edited by Webtest; Jul 22nd, 2005 at 11:51 AM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

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