Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008

    Unanswered: Write program in VBA to link AS400 through ODBC


    Is there anyone who can point me out how to create a code for the things I want?
    I am trying to create a link table through VBA.

    here is the code:

    Dim ConStr1
    Set Con1 = CreateObject("ADODB.Connection")
    Constr1 = "ODBC;Driver={iSeries Access ODBC Driver};DSN=AS400C;SYSTEM=;Database=RC HASE5C;UID=TIM;PWD=TIM123;"

    Con1.Open Constr1
    MsgBox "Connection Opened!"

    Dim td As TableDef
    Set td = currentdb.CreateTableDef("TestTable", dbAttachSavePWD, "OLSDTA.IORITEMM", Constr1)
    currentdb.TableDefs.Append td

    I got run time error '3000'. reserved error (-7778); there is no message for this error.

    I do appreciate any kind of help.



  2. #2
    Join Date
    Dec 2004
    Madison, WI
    There's some code in the code bank which creates an ODBC link via vba to SQL Server. Here it is: It's worked pretty well for me and maybe you can modify it to meet your needs.
    Last edited by pkstormy; 02-28-08 at 21:36.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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