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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening form in other database, with another Access version

Status
Not open for further replies.

flaviooooo

Programmer
Feb 24, 2003
496
FR
Sorry for the weird topic, but I have the following problem.

We work with 2 different versions MS Access through each other (not good, I know)

Now we would like to trigger a form in an Access 97-database, from a Access 2003-db.

I have done a similar action between 2 97-databases with the following code:

Code:
txtFilename = "T:\Bedruk 97.mdb"
        Set acApp = CreateObject("Access.Application")
        acApp.OpenCurrentDatabase txtFilename
        acApp.Visible = True
        acApp.DoCmd.RunCommand acCmdAppMaximize
        acApp.DoCmd.OpenForm "F_DRUKCODE", , , "[DRUKCODE]='1'"

Unfortunately, when I try to use this code between 2 different versions, it always tries to open the 97 with the Access 2003 and convert the 97-database.

Does anyone have an idea on how to achieve this??

Thanks in advance
 
How about Shell? It will allow you to include the path to Access 97. As far as I recall, this is modified from Microsoft Help.

Code:
Function OpenMDB(strPath As String) As Boolean
On Error GoTo Handle_Error
OpenMDB = False

Dim strCommand As String

Const APP_PATH As String = _
    "c:\program files\microsoft office\office\msaccess.exe"

' Build Access command line to pass to Shell function.
strCommand = """" & APP_PATH & """" & " " & """" & strPath & """" '& " /ro"

' Pass command line to Shell function. If this succeeds, pass
' the database path to the GetObject function and loop until
' the acApp object variable is initialized.

If Shell(strCommand) Then
    Do
        'On Error Resume Next
        Set AcApp = GetObject(strPath)
        DoEvents
    Loop Until Err.Number = 0
    OpenMDB = False
End If

End Function
 
I've thought about using Shell, but how can I then open the correct form and find the correct data to display?
 
More or less the same way you do now. I notice there are a couple of typos in my first post, so here goes:

Code:
Option Compare Database
[blue]Dim acApp[/blue]

Function OpenMDB(strPath As String) As Boolean
'On Error GoTo Handle_Error
OpenMDB = False

Dim strCommand As String

Const APP_PATH As String = _
    "c:\program files\microsoft office\office\msaccess.exe"

' Build Access command line to pass to Shell function.
strCommand = """" & APP_PATH & """" & " " & """" & strPath & """" '& " /ro"

' Pass command line to Shell function. If this succeeds, pass
' the database path to the GetObject function and loop until
' the acApp object variable is initialized.

If Shell(strCommand) Then
    Do
        'On Error Resume Next
        Set acApp = GetObject(strPath)
        DoEvents
    Loop Until Err.Number = 0
    OpenMDB = True
End If

End Function

[blue]Sub TryIt()
    OpenMDB "C:\Docs\Tek-Tips.mdb"
    acApp.DoCmd.OpenForm "frmForm"
End Sub[/blue]
 
Hey Remou,

thanks for your help but I have one more small issue here.

I would like to also add the workgroup information in the link. So I did this:

Code:
Function OpenMDB97(strPath As String) As Boolean
'On Error GoTo Handle_Error
OpenMDB97 = False

Dim strCommand As String

Const APP_PATH As String = _
    "C:\Program Files\Access97\Office\MSACCESS.EXE"
    
Const WG_PATH As String = _
    "w:\access97\system.mdw"

' Build Access command line to pass to Shell function.
strCommand = """" & APP_PATH & """" & " " & """" & strPath & """" & " /wrkgrp  """ & WG_PATH & """"
'strCommand = """" & APP_PATH & """" & " " & """" & strPath & """" '& " /ro"

' Pass command line to Shell function. If this succeeds, pass
' the database path to the GetObject function and loop until
' the acApp object variable is initialized.

If Shell(strCommand) Then
'    Do
        'On Error Resume Next
        Set acApp = GetObject(strPath)
        DoEvents
'    Loop Until Err.Number = 0
    OpenMDB97 = True
End If

End Function

Unfortunately, it now opens my database twice.
Once without the workgroup (always as admin), once with the workgroup.

I think the one without the workgroup is triggered in the line Set acApp = GetObject(strPath)

But if I remove this line, I would not be able to go to the correct form etc...

Any tips?
 
I have tried this and cannot replicate the problem. Can you test with a scrap database, to make sure that no other code is involved?
 
You're right, it doesn't do this with a scrap database.

I can't figure out why it does it with the one I use though??
 
I think it is some small, overlooked, piece of code that is causing the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top