Link to home
Start Free TrialLog in
Avatar of askolits
askolits

asked on

VB 2005 app and Access2010 issue with DAO - Possible Assembly Issue?

I wrote a VB 2005 program that provides an Automated LiveUpdate feature for my Access databases.

The LiveUpdate retrieves a version number in the MDB and compares it to one stored in a text file in a remote server.  If a newer version is available the download runs.

This program has been upgraded to work on Windows 7 and Access 2007.  It uses DAO for the database object. It also creates a secure workspace using dao.PrivDBEngine .

The code works fine with Win7/Access 2007.  But fails on Win7/Access2010. I made sure both the .NET framework (4.0)  and the Primary Interop Assemblies for Office 2010 are installed.
What’s odd is that my code breaks when I call my function. It does not beak within the function.
I placed some logging code right before the function call and then as the first line in the function.
It never get’s into the function.

Again, what stumps me is that it works fine with Access 2007 but not 2010.
Here is the error:
“Error : 53 Could not load file or assembly 'dao, Version=10.0.4504.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. “

The attached code has been stripped all superfluous info. (String Dimensioning, error trapping etc…)

Thanks!

J0hn
CheckLatestVersion(ByRef strAppNameWithPath As String, ByRef strSecurityFile As String, ByRef strTablename As String, ByRef strFieldName As String) As String

Dim wrkExtDB As dao.Workspace
Dim dbEXT_TABLE As dao.Database
Dim dbs As dao.Database
Dim tdf As dao.TableDef

Dim usrNew As dao.User
Dim rs As dao.Recordset
		'------------------------
Dim dbe As dao.PrivDBEngine
Dim wsp As dao.Workspace
Dim dbEXT_Database As dao.Database
Dim tbl As dao.TableDef
Dim fld As dao.Field


Dim tblCount As Short
	
'Create a secure workspace object     
dbe = New dao.PrivDBEngine
	With dbe
		strAdminUser = "ADMIN"
		strAdminPWD = "password"
		
		.SystemDB = strAPP_SecurityFile
		.DefaultUser = strAdminUser
		.DefaultPassword = strAdminPWD
	End With
 
wsp = dbe.Workspaces(0) 'systemdb is locked in now
	
'Create database object using the secure workspace
dbEXT_Database = wsp.OpenDatabase(strAppNameWithPath, False, True, strPassword)
		

tblCount = 0
		
'Look for the table ="tblTableWithVersionINfo". If found get the version number. Otherwise, return 0.001

For tblCount = 0 To dbEXT_Database.TableDefs.Count - 1

 	'If we find the table ="tblTableWithVersionINfo", then open it
	strTablename ="tblTableWithVersionINfo"
	If dbEXT_Database.TableDefs(tblCount).Name = strTablename Then 

 		rs = dbEXT_Database.OpenRecordset(strTablename)
		
		'Get the value from the field [strCurrentVersionNumber]
		strFieldName = "strCurrentVersionNumber"		
		
		If IsDbNull(rs.Fields(strFieldName).Value) Then
			CheckLatestVersion = "0"
		Else
			CheckLatestVersion = rs.Fields(strFieldName).Value
		End If
				
		rs.Close()
		rs = nothing
				
 		GoTo FinishRetrieval '(exit the app)
	 End If

Next tblCount

'If we get this far, the info was not found. Set a default version
 CheckLatestVersion = "0.001"
		
FinishRetrieval: 
        On Error Resume Next
        dbEXT_Database.Close()
        dbEXT_Database = Nothing

Exit Function

Open in new window

Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Are you sure that's the right version of DAO, and that you've referenced the correct Interops? It sounds as if you're using the incorrect version.

Check the references and report back here which you're using.

Avatar of askolits
askolits

ASKER

See attached screen shot.
Does it look right?
Thanks. User generated image
ASKER CERTIFIED SOLUTION
Avatar of puppydogbuddy
puppydogbuddy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll have to wait till Monday to take a look at thgis again. I'll let you know.
It seems the DAO reference wasn't needed. My guess is that tthe DAO objects are also in the Interop files for Access 2010. So, I think it caused a conflict. I removed the DAO reference and it's now working.
Thanks for pointing me in the right directtion.

John