Way to know form name that opens a particular form

So is the problem you can't get frmFootprint to open? or it opens but you don't know which form opened it? or both?
My suggestion solves the 2nd problem, I don't get an issue with opening the form

It is 2nd problem, I dont know which form opened it (formC)?
 
I can't set form OpenArg of formC since it is opeing from combobox click.
The calling form knows itself => Me

When using this reference, it doesn't matter if there are multiple instances of the same form as the main form, or if the form is currently being used as a subform. Me sure is selfish.

You can't pass a reference to an object using OpenArgs, this argument only takes and passes strings. But that doesn't matter. OpenArgs is a universal standard property for simple cases. In better cases, you create an OWN property in the FormC form.
Code:
Private m_ctlCallingForm As Access.Form

Public Property Get CallingForm() As Access.Form
    Set CallingForm = m_ctlCallingForm
End Property

Public Property Set CallingForm(ctlCallingForm As Access.Form)
    Set m_ctlCallingForm = ctlCallingForm
End Property

When you open the form, you pass the reference to the property, like...
Code:
DoCmd.OpenForm "FormC", ...
Set Forms("FormC").CallingForm = Me

When exiting the form, the requery can then be called:
Code:
CallingForm.Controls("Cbx_Footprint").Requery
(untested)
 
Last edited:
When you open the form, you pass the reference to the property, like...
Code:
DoCmd.OpenForm "FormC", ...
Set Forms("FormC").CallingForm = Me
I not opening formC from command_button thus now where to add this code
 
I didn't write anything about a command button. But somehow the form is opened by code. There then now by two-line.
With an open form then only the property assignment.
 
I didn't write anything about a command button. But somehow the form is opened by code. There then now by two-line.
With an open form then only the property assignment.
It opens by clicking on "Edit List Item" of combobox.... I dont see where to add the code
 
It opens by clicking on "Edit List Item" of combobox.... I dont see where to add the code
Use the double click event?
I have never used Edit List Items, never even knew it existed on right click. :)
Set a tempvar to the form name when you load the form. Then Activate that form.

Now we know why it seems so complicated, you are not using events. :(
 
I attached the sample db here, for easy evaluate the issue
Example.png
 

Attachments

Use the double click event?
I have never used Edit List Items, never even knew it existed on right click. :)
Requery on the GotFocus event of the form?
 
Use the double click event?
I have never used Edit List Items, never even knew it existed on right click. :)
Set a tempvar to the form name when you load the form. Then Activate that form.

Now we know why it seems so complicated, you are not using events. :(
No event, so cant set tempvar
 
No event, so cant set tempvar
You are telling me you have never heard of the Form_Load event?
Set a Tempvar (CurrentForm) on every form load, then activate/open that form.

Or just use an event like everyone else does? :(
 
Seems my suggestion has been totally ignored. Not going to waste any more of my time so going to drop off this thread. Good luck finding an alternative solution
 
edit: oops wrote this late last night, forgot to hit post. Posting to show NIL event.

I'm a little confused. It looks to me that you are using a value list for your combo.
I don't think a requery will make a difference.

If your combo is table based you can use the NotInList event to add items to the list. You can keep other combos current by adding a requery in the on enter event of the combo.

Here's example Not In List events in a couple of flavors.
 

Attachments

Last edited:
Please can anyone tell me why you want a Main Form based on tblFootprint with a Subform based on the same table?

What would be the purpose?
 
I see that my post with the right way to approach this has been ignored. Post #8 by me tells you how to solve this.

1.jpg

2.jpg
3.jpg
4.jpg
5.jpg




So this will requery your combo selectively:
Code:
Private Sub Form_Close()
    If InStr(Me.OpenArgs, "FrmA1") Then
        Forms.FrmB1.Form.FrmA1.Form.Cbx_Footprint.Requery
    ElseIf InStr(Me.OpenArgs, "FrmB1") Then
        Forms.FrmB1.Cbx_Footprint.Requery
    End If
End Sub
 
Last edited:
First, I looked up the ListItemsEditForm property. It says nothing about having an automatic OpenArgs tie-in. So if there WAS an open args entry, it was done manually and that means from the call that invoked the form.

However, you DO NOT CARE which form called which form. Look up the two events called _Activate and _Deactivate - which come into play when focus changes from one form to another for any reason. When focus re-enters a form, do the requery in the (still open) calling form's Form_Activate event. Let the closing form (Form C in the example) just go back to sleep.

You were trying to make form C do something nice for the form that opened it but it is a pain in the patootie to actually determine (via system calls) which form called you, and yet the suggestion to pass that information via OpenArgs seems to be met with some friction. The easiest choice is to have that calling form do its own requery, which you can do from a Form_Activate event.


Excerpt from that link: "When you switch between two open forms, the Deactivate event occurs for the form being switched from, and the Activate event occurs for the form being switched to."

So you DO NOT CARE how form C got called and you don't care whether A or B called C or you ran C directly for some reason. Put the combobox.Requery in the _Activate event for each of A and B. At worst, this causes 1 extra .Requery when you open the form for its first use. AND if you were to directly open C (for testing, e.g.) it doesn't have to look for something that wasn't there in the first place.
 

Users who are viewing this thread

Back
Top Bottom