Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ODBC connection with vba code on startup (2003)

    Hello friends, It's my first time reading and posting here. I stumbled upon this site from google.

    I am looking for a way to Create an ODBC connection with vba code and AutoExec it on startup? So that when the user clicks on my db application, he is automatically connected through ODBC.

    I currently have this code, but it's not working. I still get "ODBC - connection to 'MY_SEVER' failed. prompting the user to setup their odbc connection. I run this code from the Autoexec macro. There's obviously something i am not doing right. Can anyone help me?

    <code>Public Function RegSybase() As Boolean
    Dim ws As Workspace
    Dim db As Database
    Dim strConnection As String

    Set ws = DBEngine.Workspaces(0)

    Let strConnection = "ODBC;DSN=NY_HIG_LEND;NLN=Winsock;NA=lnbsdb88,XXXX ;DATABASE=sdfdfdfdj;UID=user;PWD=user"
    Set db = ws.OpenDatabase("", False, False, strConnection)

    End Function

    </code>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ODBC connection with vba code on startup (2003)

    Welcome to Woody's Lounge!

    What kind of database are you trying to connect to? And why don't you create linked tables manually? That way you won't have to reconnect in code.

  3. #3
    New Lounger
    Join Date
    Feb 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ODBC connection with vba code on startup (2003)

    Thanks Hans [img]/forums/images/smilies/smile.gif[/img]
    They are sybase tables.

    I have linked the tables manually. the tables are already set.
    Even though there are linked tables in the appl. my users still get the connect to odbc dialogue.

    So that's why i put that code to do it on startup. How do i connect to my server?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ODBC connection with vba code on startup (2003)

    I hope someone else will jump in; I have no experience with connecting to Sybase.

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: ODBC connection with vba code on startup (2003)

    Sorry - I've been travelling most of the last two weeks, so apologies for not responding sooner. In order to help we will need some additional details. What ODBC driver are you trying to use? Sybase tables are closely related to SQL Server tables, but I'm not sure whether the Microsoft driver for SQL Server will work or not. Also, the ODBC data source must be defined on each PC that connects to the back-end, and the security model being used will need to be explored. You will probably want to define a user in Sybase for each person that connects to the database so you can identify who makes changes. Hope this helps.
    Wendell

Posting Permissions

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