How to open a form in another database and filter it.

PierreR

Registered User.
Local time
Today, 17:20
Joined
Jul 21, 2004
Messages
101
Does anybody know how to open a form in another database from a current database, filtered for the id of the current record?

Much appreciated, Pierre.
 
Access 2002

The code is adapted from what was found on this forum and Wizard-code. It opens at the right form, but not the right record.

Code:
Public Sub OpenADatabase(ByVal strPath As String, ByVal strFrm As String, ByVal strLC As String)
Dim appAccess As Object

Set appAccess = CreateObject("Access.Application")

With appAccess
    .OpenCurrentDatabase strPath
    .Visible = True
    .DoCmd.OpenForm strFrm, acNormal, , , , acWindowNormal
    
    End With

End Sub


Code:
Private Sub cmdHuman_Click()
On Error GoTo Err_cmdHuman_Click
Dim strFrmName As String
Dim strPathName As String
Dim strLCName As String

strPathName = "C:\Documents and Settings\All Users\Documents\AccessThings\Worklogs_Pierre\People.mdb"
strFrmName = "Relationship Form"
strLCName = "ContactPersonsID=" & Me.[PersonID]

OpenADatabase strPathName, strFrmName, strLCName

Exit_cmdHuman_Click:
    Exit Sub

Err_cmdHuman_Click:
    MsgBox Err.Description
    Resume Exit_cmdHuman_Click
    
End Sub
 
Uncle Gizmo,

I really appreciate your reference, but if you look at my code, that link is where I got it.

The next interesting code would be how to make a specific record open. I have tried it up there but it did not work.

Pierre.

SORRY. IGNORE ABOVE. It is changed and seems really great. I'll check it out and see if it works. Thank you.
 
Last edited:
It seems in your new code that the reference is to ExpectationDesc. Would it not be better to connect the ExpectationID's?
 
- because in a large database the search for the string is not going to have a specific result, if indeed that is what is happening.

Maybe one could specify the ID field of both the front-end form and the back-end form in the code?
 
Sorry, Uncle Gizmo,

It actually works somehow, still going to the right ID if the string is the same in two different records. Amazing thing, this coding!

Could you tell me why it works, because it seems that the code does not refer to the ID's?

Pierre.
 
Okay guys. I'm demonstrating my ignorance. The answer is in the Public Function called OpenADatabase. Sorry for my ignorance, Uncle Gizmo, and thanks a lot!

Pierre.
 

Users who are viewing this thread

Back
Top Bottom