Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3343 Unrecognised database format

Status
Not open for further replies.

Peps

Programmer
Feb 11, 2001
140
ES
I'm unable to come up with the soloution after reading up on the related threads. I have a database that is linked to a backend. I'm trying to simulate a multiuser enviroment on my PC by using the same MDE (Front-End) twice (One with a different name, different location, different user). Any one of the two MDE's can be opened without any problems at all, however when the second application is opended I get the "Run-timeError 3343, The database format 'C:\Program Files\My Database\Data.Mdb is not recognised," (But only 5 times out of 10)???

I'm using the references DAO 3.6 & ADO 2.5
I changed the ADO 2.5 from ADO 2.1 after reading the related threads. (Still no luck)

This is a real twister because this error shows after the second database is open, not only that, I can carry on working if the error is ignored????

Any Ideas???
Thanks Peps
[hammer]



 
Maybe some questions to consider.

Are you always opening one first and the other has the problem or does the same problem happen when either FE is opened first?

Are the same OS's on the different PC's?

Are the same versions of all libraries the same on both PC's?

Is the backend database mdb on one of the PC's or another PC?
 
Maybe I did not make it too clear, I'm only using one PC, (O.S. is Windows XP) Both front-ends are the same, the only difference is that one is called Version 2 and is located in a different folder to the other. With regards to the your last question: It make no difference which MDE is executed first, the error always comes up on the second application. It's strange each time I debug I get a different Error, I mean a different line of code is highlighted each time!

 
Thanks for the info, I've checked out the comments made by Microsoft and to be honest I'm still in the dark. I already have MDAC 2.5 installed and I'm still getting this error. If the back-end is an Access2000 Mdb and the front-end is also Access2000, how can the application not recognise the database? - Is there and easy way of getting around this horrible error? What can I expect when the Back-end is on a server and the front-ends are on seperate work stations?
 
Are you using any DAO objects in you code? If so, paste in the code. What reference libraries do you have checked in both the front and back end mdb's?

 
No, no DAO objects are being used, I've just downloaded and installed MDAC 2.7 and that dosent work either! I have a form called Access that has a module in Timer, this checks to see if the active user has received a message, If so a pop-up message tells the user that he/she has received a message.
This form is the first form that opens after the user enters the database and is the form where the DB crashes.

The error pops up anywhere and at any time? - As said before, 5 times out of ten.

The references in use are:

Visual Basic for Applications
Microsoft Access 9.0 Object Library
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.7 Library
OLE Automation

Still playing around with it.... Any Ideas?




 
Have you run Compact and Repair which is found under
Tools
Databases Utilities
Compact and Repair

 
I normally run Compact and Repair every time I modify the database. I also have the 'Compact on Close' selected on each database. Am I to beleive that this error will show no matter where the front-end is located? There must be a way around this. Thanks for keeping up with your info/help.
Peps.
 
Everything I have read points to the 3343 error as coming from the Jet 3.51 engine/file format. Access 97 uses Jet 3.51 while Access 2000 and greater uses the Jet 4.0 engine/file format. Also, Access 97 uses DAO as the default for its data objects. The error seems to indicate that DAO expects the Jet 3.51 format.

Were your MDB's orginally up sized from Access 97?

If you remove your references to DAO 3.6 then recompile the App, there should be no error since the DAO is not being used. If you get an error after removing the reference it should point to where DAO is being used and that would be the area to look for the problem.
 
Ok, I've got ya, my Mdb was created in Access2000, I did however copy and modify a code from the Northwind database (Access97) and added the DAO 3.6 so that this module would keep running. I've changed the Reference to DAO 3.51 and it seems to be running ok. I'm not really up with references and all their functions, do you think that by changing from DAO 3.6 to DAO 3.51 will kill this error once and for all? What reference would you suggest. Peps
 
Not sure, but can you paste in the code you borrowed from the Northwind mdb so I can take a look at it and maybe make some suggestions. It is probably causing the problem the way it is configured.
 
Here's the code:


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RefreshTableLinks '
' '
' This module contains functions that refresh the '
' links to Northwind tables if they aren't available. '
' '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit ' Require variables to be declared before being used.
Option Compare Database ' Use database order for string comparisons.

Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Boolean
Declare Function GetSaveFileName Lib "comdlg32.dll" Alias _
"GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Boolean

Type MSA_OPENFILENAME
' Filter string used for the Open dialog filters.
' Use MSA_CreateFilterString() to create this.
' Default = All Files, *.*
strFilter As String
' Initial Filter to display.
' Default = 1.
lngFilterIndex As Long
' Initial directory for the dialog to open in.
' Default = Current working directory.
strInitialDir As String
' Initial file name to populate the dialog with.
' Default = "".
strInitialFile As String
strDialogTitle As String
' Default extension to append to file if user didn't specify one.
' Default = System Values (Open File, Save File).
strDefaultExtension As String
' Flags (see constant list) to be used.
' Default = no flags.
lngFlags As Long
' Full path of file picked. When the File Open dialog box is
' presented, if the user picks a nonexistent file,
' only the text in the "File Name" box is returned.
strFullPathReturned As String
' File name of file picked.
strFileNameReturned As String
' Offset in full path (strFullPathReturned) where the file name
' (strFileNameReturned) begins.
intFileOffset As Integer
' Offset in full path (strFullPathReturned) where the file extension begins.
intFileExtension As Integer
End Type

Const ALLFILES = "All Files"

Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As Long
nMaxCustrFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustrData As Long
lpfnHook As Long
lpTemplateName As Long
End Type

Const OFN_ALLOWMULTISELECT = &H200
Const OFN_CREATEPROMPT = &H2000
Const OFN_EXPLORER = &H80000
Const OFN_FILEMUSTEXIST = &H1000
Const OFN_HIDEREADONLY = &H4
Const OFN_NOCHANGEDIR = &H8
Const OFN_NODEREFERENCELINKS = &H100000
Const OFN_NONETWORKBUTTON = &H20000
Const OFN_NOREADONLYRETURN = &H8000
Const OFN_NOVALIDATE = &H100
Const OFN_OVERWRITEPROMPT = &H2
Const OFN_PATHMUSTEXIST = &H800
Const OFN_READONLY = &H1
Const OFN_SHOWHELP = &H10

Function FindNorthwind(strSearchPath) As String
' Displays the Open dialog box for the user to locate
' the Northwind database. Returns the full path to Northwind.

Dim msaof As MSA_OPENFILENAME

' Set options for the dialog box.
msaof.strDialogTitle = "Explorer de Gestión y Control."
msaof.strInitialDir = strSearchPath
msaof.strFilter = MSA_CreateFilterString("Databases", "*.mdb")


' Call the Open dialog routine.
MSA_GetOpenFileName msaof

' Return the path and file name.

FindNorthwind = Trim(msaof.strFullPathReturned)



End Function


Function MSA_CreateFilterString(ParamArray varFilt() As Variant) As String
' Creates a filter string from the passed in arguments.
' Returns "" if no argumentss are passed in.
' Expects an even number of argumentss (filter name, extension), but
' if an odd number is passed in, it appends "*.*".

Dim strFilter As String
Dim intRet As Integer
Dim intNum As Integer

intNum = UBound(varFilt)
If (intNum <> -1) Then
For intRet = 0 To intNum
strFilter = strFilter & varFilt(intRet) & vbNullChar
Next
If intNum Mod 2 = 0 Then
strFilter = strFilter & &quot;*.*&quot; & vbNullChar
End If

strFilter = strFilter & vbNullChar
Else
strFilter = &quot;&quot;
End If

MSA_CreateFilterString = strFilter
End Function

Function MSA_ConvertFilterString(strFilterIn As String) As String
' Creates a filter string from a bar (&quot;|&quot;) separated string.
' The string should pairs of filter|extension strings, i.e. &quot;Access Databases|*.mdb|All Files|*.*&quot;
' If no extensions exists for the last filter pair, *.* is added.
' This code will ignore any empty strings, i.e. &quot;||&quot; pairs.
' Returns &quot;&quot; if the strings passed in is empty.


Dim strFilter As String
Dim intNum As Integer, intPos As Integer, intLastPos As Integer

strFilter = &quot;&quot;
intNum = 0
intPos = 1
intLastPos = 1

' Add strings as long as we find bars.
' Ignore any empty strings (not allowed).
Do
intPos = InStr(intLastPos, strFilterIn, &quot;|&quot;)
If (intPos > intLastPos) Then
strFilter = strFilter & Mid(strFilterIn, intLastPos, intPos - intLastPos) & vbNullChar
intNum = intNum + 1
intLastPos = intPos + 1
ElseIf (intPos = intLastPos) Then
intLastPos = intPos + 1
End If
Loop Until (intPos = 0)

' Get last string if it exists (assuming strFilterIn was not bar terminated).
intPos = Len(strFilterIn)
If (intPos >= intLastPos) Then
strFilter = strFilter & Mid(strFilterIn, intLastPos, intPos - intLastPos + 1) & vbNullChar
intNum = intNum + 1
End If

' Add *.* if there's no extension for the last string.
If intNum Mod 2 = 1 Then
strFilter = strFilter & &quot;*.*&quot; & vbNullChar
End If

' Add terminating NULL if we have any filter.
If strFilter <> &quot;&quot; Then
strFilter = strFilter & vbNullChar
End If

MSA_ConvertFilterString = strFilter
End Function

Private Function MSA_GetSaveFileName(msaof As MSA_OPENFILENAME) As Integer
' Opens the file save dialog.

Dim of As OPENFILENAME
Dim intRet As Integer

MSAOF_to_OF msaof, of
of.Flags = of.Flags Or OFN_HIDEREADONLY
intRet = GetSaveFileName(of)
If intRet Then
OF_to_MSAOF of, msaof
End If
MSA_GetSaveFileName = intRet
End Function

Function MSA_SimpleGetSaveFileName() As String
' Opens the file save dialog with default values.

Dim msaof As MSA_OPENFILENAME
Dim intRet As Integer
Dim strRet As String

intRet = MSA_GetSaveFileName(msaof)
If intRet Then
strRet = msaof.strFullPathReturned
End If

MSA_SimpleGetSaveFileName = strRet


End Function

Private Function MSA_GetOpenFileName(msaof As MSA_OPENFILENAME) As Integer
' Opens the Open dialog.

Dim of As OPENFILENAME
Dim intRet As Integer

MSAOF_to_OF msaof, of
intRet = GetOpenFileName(of)
If intRet Then
OF_to_MSAOF of, msaof
End If
MSA_GetOpenFileName = intRet
End Function

Function MSA_SimpleGetOpenFileName() As String
' Opens the Open dialog with default values.

Dim msaof As MSA_OPENFILENAME
Dim intRet As Integer
Dim strRet As String

intRet = MSA_GetOpenFileName(msaof)
If intRet Then
strRet = msaof.strFullPathReturned
End If

MSA_SimpleGetOpenFileName = strRet
End Function

Public Function CheckLinks() As Boolean
' Check links to the Northwind database; returns True if links are OK.

Dim Dbs As Database, rst As Recordset
Set Dbs = CurrentDb

' Open linked table to see if connection information is correct.
On Error Resume Next
Set rst = Dbs.OpenRecordset(&quot;Inicio&quot;)

' If there's no error, return True.
If Err = 0 Then
CheckLinks = True

Else
CheckLinks = False

End If

End Function

Private Sub OF_to_MSAOF(of As OPENFILENAME, msaof As MSA_OPENFILENAME)
' This sub converts from the Win32 structure to the Microsoft Access structure.

msaof.strFullPathReturned = Left(of.lpstrFile, InStr(of.lpstrFile, vbNullChar) - 1)
msaof.strFileNameReturned = of.lpstrFileTitle
msaof.intFileOffset = of.nFileOffset
msaof.intFileExtension = of.nFileExtension
End Sub

Private Sub MSAOF_to_OF(msaof As MSA_OPENFILENAME, of As OPENFILENAME)
' This sub converts from the Microsoft Access structure to the Win32 structure.

Dim strFile As String * 512

' Initialize some parts of the structure.
of.hwndOwner = Application.hWndAccessApp
of.hInstance = 0
of.lpstrCustomFilter = 0
of.nMaxCustrFilter = 0
of.lpfnHook = 0
of.lpTemplateName = 0
of.lCustrData = 0

If msaof.strFilter = &quot;&quot; Then
of.lpstrFilter = MSA_CreateFilterString(ALLFILES)
Else
of.lpstrFilter = msaof.strFilter
End If
of.nFilterIndex = msaof.lngFilterIndex

of.lpstrFile = msaof.strInitialFile _
& String(512 - Len(msaof.strInitialFile), 0)
of.nMaxFile = 511

of.lpstrFileTitle = String(512, 0)
of.nMaxFileTitle = 511

of.lpstrTitle = msaof.strDialogTitle

of.lpstrInitialDir = msaof.strInitialDir

of.lpstrDefExt = msaof.strDefaultExtension

of.Flags = msaof.lngFlags

of.lStructSize = Len(of)
End Sub

Private Function RefreshLinks(strFileName As String) As Boolean
' Refresh links to the supplied database. Return True if successful.

Dim Dbs As Database
Dim tdf As TableDef

' Loop through all tables in the database.
Set Dbs = CurrentDb
For Each tdf In Dbs.TableDefs
' If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
tdf.Connect = &quot;;DATABASE=&quot; & strFileName
Err = 0
On Error Resume Next
tdf.RefreshLink ' Relink the table.
If Err <> 0 Then
RefreshLinks = False
Exit Function
End If
End If
Next tdf

RefreshLinks = True ' Relinking complete.



End Function

Public Function RelinkTables() As Boolean
' Tries to refresh the links to the Northwind database.
' Returns True if successful.

Dim strAccDir As String
Dim strSearchPath As String
Dim strFileName As String
Dim intError As Integer
Dim StrError As String

Const conMaxTables = 59
Const conNonExistentTable = 3011
Const conNotData = 3078
Const conNwindNotFound = 3024
Const conAccessDenied = 3051
Const conReadOnlyDatabase = 3027
Const conAppTitle = &quot;Gestión y Control - V.2.0&quot;

' Get name of directory where MSAccess.exe is located.
strAccDir = SysCmd(acSysCmdAccessDir)



' Get the default sample database path.
If Dir(strAccDir & &quot;Data\.&quot;) = &quot;&quot; Then
strSearchPath = strAccDir
Else
strSearchPath = strAccDir & &quot;Data\&quot;
End If

' Look for the Northwind database.
If (Dir(strSearchPath & &quot;Data.mdb&quot;) <> &quot;&quot;) Then
strFileName = strSearchPath & &quot;Data.mdb&quot;
Else
' Can't find Northwind, so display the Open dialog box.
MsgBox &quot;Gestión y Control no encontró la base de datos. &quot; & &quot;Buscar la base de datos de Gestión y Control ahora.&quot;, vbExclamation
strFileName = FindNorthwind(strSearchPath)

If strFileName = &quot;&quot; Then
StrError = &quot;Tiene que localizar la base de datos de Gestión y Control antes de poder utilizar esta aplicación.&quot;
GoTo Exit_Failed
End If

End If


' Fix the links.

If RefreshLinks(strFileName) Then
RelinkTables = True
Exit Function

End If


' If it failed, display an error.

Select Case Err
Case conNonExistentTable, conNotData
StrError = &quot;File '&quot; & strFileName & &quot;' no contiene la información de Gestión y Control.&quot;

Case Err = conNwindNotFound
StrError = &quot;No puedes utilizar &quot; & conAppTitle & &quot; hasta que localices la base de datos de Gestión y Control.&quot;

Case Err = conAccessDenied
StrError = &quot;No se puede abrir Gestíon y Control &quot; & strFileName & &quot; La base de datos es sólo de lectura.&quot;

Case Err = conReadOnlyDatabase
StrError = &quot;No se puede vincular la base de datos &quot; & conAppTitle & &quot; La base de datos es sólo de lectura o está bloqueada.&quot;

Case Else
StrError = Err.Description

End Select

Exit_Failed:
MsgBox StrError, vbCritical
RelinkTables = False

End Function

The above code is used for checking the links to the back-end, case the back-end is moved the user can relink by using a browser. (This code is works better than perfect)
Peps.
 
Differences between DAO and ADO.



The code causing the problem relates to the DAO data objects. Find and explicitly define and leave the reference set to DAO 3.6.

Dim Dbs As DAO.Database, rst As DAO.Recordset

Make sure you find all definitions to DAO data objects and prefix with DAO like in the above example.

Another alternative is to check to Microsoft site for an example of how to relink tables using ADO instead of DAO. In ADO it uses a reference to the ADOX library.
 
It seems that the error has gone. I'm gonna have a read on the stated links anyway. Many thanks. Peps [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top