Solved

Identify what the parent of a subform is

Posted on 2011-09-14
5
267 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
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 33

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 84
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
On Key Down Access 2010 6 41
Sum in Split Form 17 27
Create Incremental Count and Reset Counter for Field Change in Access 14 36
Access Web App or PowerApp 24 34
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 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