This code use to work with 2013 Word 32 bit and now its not working with 2021 Word 64 bit.
Public Benzdb As Database
Public sconnection As String
Sub ConnecttoDatabase()
'Production System ODBC
sconnection = OdbcConnection("dbBenz", "Benz", "username", "password")
Set Benzdb = Workspaces(0).OpenDatabase("Benz", False, False, sconnection)
End Sub
Sub CloseDatabase()
Acedb.Close
End Sub
Public Function OdbcConnection(ByVal AceDatabaseName As String, ByVal AceDataSourceName As String, Aceuserid As String, AcePassWord As String) As String
ODBCConnectString = "ODBC" _
& ";DATABASE=" & BenzDatabaseName _
& ";UID=" & Benzuserid _
& ";PWD=" & BenzPassWord _
& ";DSN=" & BenzDataSourceName
End Function
CodePudding user response:
It looks like you have an older 32 bit reference to DAO
Try unchecking the DAO library and then scrolling down to check Microsoft Office ## Access database engine Object Library
- then run Debug | Compile
to see if it allows Workspaces