A family of Microsoft relational database management systems designed for ease of use.
Maybe:
If Me.Parent.Name = "f_to_do_det_e" Then
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using the same exact data entry subform on 2 forms. I'd like to have one piece of code for each usage of this particular data entry subform, but I have failed. I've used: If Me.Parent = f_to_do_det_e Then AND Ive tried If Me..Parent.Name = f_to_do_det_e
Nothing I've tried works. One of the parent forms is f_to_do_det_e and the other is f_to_do_itm_det_e_pop
Private Sub cbo_to_do_ctg_m_ctg__AfterUpdate()
On Error GoTo Err_cbo_to_do_ctg_m_ctg__AfterUpdate
If Me.Parent.Name = f_to_do_det_e Then
If Me.Dirty = True Then Me.Dirty = False
[Forms]![f\_to\_do\_det\_e]![fsb\_to\_do\_ctg\_lst\_ve].Requery
DoCmd.GoToRecord , , acNewRec
End If
Else
If Me.Dirty = True Then Me.Dirty = False
[Forms]![f\_to\_do\_itm\_det\_e\_pop]![fsb\_to\_do\_ctg\_lst\_ve].Requery
DoCmd.GoToRecord , , acNewRec
End If
End If
Exit_cbo_to_do_ctg_m_ctg__AfterUpdate:
Exit Sub
Err_cbo_to_do_ctg_m_ctg__AfterUpdate:
MsgBox Err.Description
Resume Exit\_cbo\_to\_do\_ctg\_m\_ctg\_\_AfterUpdate
End Sub
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Maybe:
If Me.Parent.Name = "f_to_do_det_e" Then
Answer accepted by question author
> If Me.Parent = f_to_do_det_e
The Parent property, per the help file, returns the parent OBJECT for the specified object.
Yes, it's a shame that the item to be defined is used to define it. Out of my control :-)
But this means that the subform's Parent OBJECT is being returned.
f_to_do_det_e is not a (form) object. It is the name of such object.
If you try to Debug > Compile this code, you will get an error.
> If Me..Parent.Name = f_to_do_det_e
The Name property, per the help file, returns the string expression that identifies the name of an object.
Yes, it's a shame that the item to be defined is used to define it. Out of my control :-)
f_to_do_det_e is not a string.
If you try to Debug > Compile this code, you will get an error.
Armed with this understanding, it appears you can correctly write your code by comparing two objects, or two strings.
Unfortunately when you try, you will find that comparing two objects is not possible.
If Me.Parent = Forms!f_to_do_det_e > Type Mismatch.
But you CAN compare two strings:
If Me.Parent.Name = "f_to_do_det_e" then MsgBox "Eureka!"
I am using the same exact data entry subform on 2 forms. I'd like to have one piece of code for each usage of this particular data entry subform,
Hi VWP1,
You could try something like this:
Private Sub cbo_to_do_ctg_m_ctg__AfterUpdate()
If (Me.Dirty) Then Me.Dirty = False Me.Parent![fsb\_to\_do\_ctg\_lst\_ve].Requery DoCmd.GoToRecord , , acNewRecEnd Sub
In the above example, I assume Me represents the subform.
And DoCmd.GoToRecord, is that command for the Parent-form?
Imb.
I'm not clear on what the problem is here, (besides incorrect code). When you embed a subform using the subform wizard, you are asked if you want to select an existing form. Doing so and selecting the same form on both mainforms will place the same subform on both mainforms. I don't see any need for code. here.
Now if you want to use different subfoms on the same mainform, then you would use code to adjust the subforms Source property with the name of the subform.