Solved

Identify what the parent of a subform is

Posted on 2011-09-14
5
270 Views
Last Modified: 2012-06-22
I have two forms that both use a comments subform.  However, depending on which group opens the form is which textbox for the Claim id to be drawn from.  I tried the Me.Parent, but that did not work to identify which form the subform was being used on.
Private Sub CmdNew_Click()
On Error GoTo Err_CmdNew_Click

    DoCmd.OpenForm "FrmNotesView"
    DoCmd.GoToRecord , , acNewRec

If Me.Parent = Forms!frmACHClaims Then
    Forms.FrmNotesView.TxtClaimID = Forms!frmACHClaims!TxtClaimID
    Forms.FrmNotesView.ComClaimID = Forms!frmACHClaims!TxtClaimID
ElseIf Me.Parent = Forms!FrmClaims Then
    Forms.FrmNotesView.TxtClaimID = Forms!FrmClaims!TxtClaimID
    Forms.FrmNotesView.ComClaimID = Forms!FrmClaims!TxtClaimID
End If

Exit_CmdNew_Click:
    Exit Sub
Err_CmdNew_Click:
        MsgBox "Error Number: " & Err.Number & _
           "Description: " & Err.Description & _
           "Procedure: CmdNew_Click", vbOKOnly, "Error Message"
    Resume Exit_CmdNew_Click
    
End Sub

Open in new window

0
Comment
Question by:ssmith94015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 36539858
Me.Parent.Name will give you the actual name of the form that the subform resides on.
0
 
LVL 34

Expert Comment

by:Norie
ID: 36539860
Me.Parent should work, where/how  did you try it?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 36539862
ie:

If Me.Parent.Name = "frmACHClaims" Then
0
 
LVL 85
ID: 36541990
<no points please>

The other Experts have provided you with the fix, but your code isn't working because you're comparing the value of Me.Parent (which returns a string value containing the name of the Parent form, if there is one), with the value of Forms!frmACHClaims, which would return a Form object. You could fix it as described by mbizup, or you could do this:

Me.Parent = Forms!frmACHClaims.Name

This would return the Name of that form (which would be "frmACHClaims"), instead of the Form object.
0
 

Author Closing Comment

by:ssmith94015
ID: 36543391
And thanks to LMConsulting for the explanation.  This does precisely what I want.

Sandra
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question