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

can't open form based on field in subform

Status
Not open for further replies.

guayabita

MIS
Jun 10, 2004
13
US
Hello,

I have a form [frmIndividual] with a subform [sbfOrgsContact]. The form shows a list of organizations for wich the individual is the main contact. I would like to double click the field/name of the organization [Org_NAME] and have another form [frmOrg] open up with the record based on [Org_ID] wich is not displayed in subform. [Org_ID] is part of table the underlying subform (on the first form) and newly opened form are based upon.

First Form:
frmIndividual
sbfOrgsContact
Org_Name (from ORG table that has Org_ID)

Second form:
frmOrg (from ORG table that has Org_ID)


I have set a doublClick event macro with the condition is:
Code:
[Org_ID]=Forms![sbfOrgsContact]![Org_ID]

This has been th only condition that has partially worked. It only works from the subform. When I open the form and select the field in the subform I get a message asking for the paramenter name "Forms![sbfOrgsContact]![Org_ID]
".

Any suggestions or explanations?

Thanks!!!
 
Have you tried this ?
[Org_ID]=Forms!frmIndividual!sbfOrgsContact.Form!Org_ID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV,

I have tried that and get the same message to enter the paramter (with the everything past the = as paramete name). One thing that may be funky is that when I upen the macro back up it shows

[Org_ID]=[Forms]![frmIndividual]![sbfOrgsContact].[Form]![Org_ID]

as the condition. I'm not sure what effect the bracket's is having.

 
Also posted in another message:

Well,

It's a total hack but it works.

Here is what I did:

1. i just added an Org_ID field to sbfOrgsContact and made it invisible
2. added a button to open the new form using the wizard and Org_ID to match on
3. I copied the code for this button to the event I had for double clicking on the Org_Name field (repplaced the names where appropriate)

Here is the wizard created code:
Code:
Private Sub Org_Name_DblClick(Cancel As Integer)
On Error GoTo Err_Org_Name_DblClick

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmOrg"
    
    stLinkCriteria = "[Org_ID]=" & Me![Org_ID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Org_Name_DblClick:
    Exit Sub

Err_Org_Name_DblClick:
    MsgBox Err.Description
    Resume Exit_Org_Name_DblClick
       
End Sub

Thanks for your suggestions PHV!
 
Hi!

For future reference, use the following syntax to access a control on a subform:

Forms!YourMainForm!YourSubFromControlName.Form!YourControl

Note: you do not use the name of the subform, rather use the name of the subform control.

hth


Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top