Solved

Identify what the parent of a subform is

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

This collection of functions covers all the normal rounding methods of just about any numeric value.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

786 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