2002 vs 2003 check version ?

qwertyjjj

Registered User.
Local time
Today, 05:31
Joined
Aug 8, 2006
Messages
262
I designed my DB and forms in Access 2003.
A user opened it up in 2002 and it errored due to some missing references.

Is there a way to add code to my startup form that can check whether the version of Access is 2003 or not before carrying on ?
 
are you using an mde file?

access 2002 wont run an access 2003 mde file, but will run an access 2003 mdb file
 
As long as you are using the Access 2000 database format (which is the normal default unless you change it after installing 2003 or 2002) and running an mdb, as noted above by gemma...you should be able to do things on a 2002 machine. But, you will need code to refresh the references.

Try using this code by putting it in a standard module and starting it using Autoexec:
Code:
Function CheckRefs()
   Dim db As Database, rs As Recordset
   Dim x
   Set db = CurrentDb

   On Error Resume Next


 
    If Err.Number <> 0 Then
      Err.Clear
      FixUpRefs
   End If   
   

End Function


Sub FixUpRefs()
    Dim loRef As Access.Reference
    Dim intCount As Integer
    Dim intX As Integer
    Dim blnBroke As Boolean
    Dim strPath As String

    On Error Resume Next

    'Count the number of references in the database
    intCount = Access.References.Count
  
    'Loop through each reference in the database
    'and determine if the reference is broken.
    'If it is broken, remove the Reference and add it back.
    For intX = intCount To 1 Step -1
      Set loRef = Access.References(intX)
      With loRef
        blnBroke = .IsBroken
        If blnBroke = True Or Err <> 0 Then
          strPath = .FullPath
          With Access.References
            .Remove loRef
            .AddFromFile strPath
          End With
        End If
       End With
    Next
    
  Set loRef = Nothing
  
  ' Call a hidden SysCmd to automatically compile/save all modules.
  Call SysCmd(504, 16483)
End Sub
 
Last edited:
Thanks, does this autoamtically fix references to Excel and Access , etc. For example, I have the 11.0 objects library, How will Access know which library to fix it up to ?
Also, what do you mean by start using autoexec? Do you mean an autoexec macro? Not sure if Access 2003 has that and it seems to error when compiling the code on the 2002 machine?
 
Last edited:
What happens is that the reference to your later version is removed and it will automatically set a reference to the version that you actually have on the machine - much like the manual method where you just go in and uncheck the box and then when you open it back up it has selected your current version. The only thing that won't work is if you use any properties or methods that weren't available in the previous version.

As for autoexec, create a macro (macro and not module) called autoexec and put the runcode command in and point to your reference refresh. Make sure to put code in the same module to run your startup form after it has finished. Do not select a startup form in the Startup properties as the module will open the form and you want the autoexec to happen prior to the form being opened.
 
You did ask, however, if there is a way to add code to your startup form that can check whether the version of Access is 2003 or not before carrying on. Here is the built-in function:
Code:
SysCmd(acSysCmdAccessVer)
Access 2002 returns 10.0 for the result; Access 2003 returns 11.0.
 
Thanks.
Out of interest, if I put that in a startup form, won't it still error in 2002?
The reason I ask is because the error tht came up the other day occurred before any command buttons had been pressed. It was an immediate runtime error in the VBA code.
Is all the code compiled before the database is opened?
 
The code is not compiled unless you manually compile it, or unless you convert the file to an MDE file.
 
If a form thathas code behind it is opened then code is compiled and therefore if bad references exist an error will occur before the auto code will exist. The same thing with the module and that is why the code uses the on error event to fix the situation.

I can work with you on fixing this. I can't do anything until after work.
 

Users who are viewing this thread

Back
Top Bottom