Results 1 to 17 of 17

Thread: Convert VB to VBA

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    272

    Convert VB to VBA

    How would this procedure be converted to VBA?
    Code:
    Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
        (ByVal hwndParent As Long, ByVal fRequest As Long, _
        ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long
        Public DB As ADODB.Connection
        Public connString As String
     
    Public Sub Connect()
        Call Create
        
        connString = "DSN=VRRS;"
        Set DB = New ADODB.Connection
        DB.Open connString
    End Sub
     
    Private Function CreateAccessDSN(DSNName As String, DatabaseFullPath As String) As Boolean
        Dim sAttributes As String
        sAttributes = "DSN=" & DSNName & Chr(0)
        sAttributes = sAttributes & "DBQ=" & DatabaseFullPath & Chr(0)
        CreateAccessDSN = CreateDSN("Microsoft Access Driver (*.mdb)", sAttributes)
    End Function
     
    Private Function CreateDSN(Driver As String, Attributes As String) As Boolean
        CreateDSN = SQLConfigDataSource(0&, 1, Driver, Attributes)
    End Function
     
    Private Sub Create()
        Dim blnRetVal As Boolean
        blnRetVal = CreateAccessDSN("VRRS", "C:\VRRS\VRRS.mdb")
    End Sub
    What I am trying to do is use VBA to set up a DSN on my PC
    Last edited by Jo15765; May 3rd, 2013 at 01:28 PM.

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