Results 1 to 2 of 2
  1. #1
    samye is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    9

    Access DAO or ODBC to Word


    Hello,

    I have found some code to do a recordset in Word VBA to bring back some data from an Access database. I was getting an error that the db was corrupted but I don't think that is the issue. I am on Win 10 Pro, Access 365. The db was created as an mdb and then later merged into an accdb. i think that has something to do with it. I had googled but do not quite understand it. Anyway, I am doing something very simple and unsure of the best method. The feature of reading the db only needs to be on two PCs, so I can setup an ODBC connection for just that PC. In Word VBA, I had added references for DAO and Microsoft 16 Access. I received a 3343 error and I think it has to do with my references.
    Thank you,
    Carol

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    i use this:

    Code:
    Dim con As ADODB.Connection
    dim rs As ADODB.Recordset
    Dim DB
    Dim vProvid
    
    
    Set con = New ADODB.Connection
    Set rs = New ADODB.Recordset
     
     uid = "" 
     pwd = ""
     DB = "\\myserver\production\Generic104J.accdb"
     vProvid = "Microsoft.Jet.OLEDB.4.0"           '  "SQLOLEDB"
     
      
    With con
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Properties("User ID").Value = uid
        .Properties("Password").Value = pwd
        
        .Open "Data Source=" & DB 
    End With
     
    Set rs = con.Execute("qsNames_simps")
    
    
    rs.Close
    con.Close
    
    
    set rs = nothing
    set con = nothing

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-25-2018, 10:32 AM
  2. Replies: 1
    Last Post: 03-02-2015, 09:44 AM
  3. Replies: 6
    Last Post: 08-13-2014, 10:32 PM
  4. Access to Word - Multiple Word Templates?
    By alpinegroove in forum Programming
    Replies: 11
    Last Post: 06-12-2012, 04:42 PM
  5. Replies: 5
    Last Post: 10-25-2011, 08:01 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
  •  
Other Forums: Microsoft Office Forums