Way to know form name that opens a particular form (1 Viewer)

CJ_London

Super Moderator
Staff member
Local time
Today, 01:58
Joined
Feb 19, 2013
Messages
16,616
We dont know which the form name called formC... since formC is opened from combobox. And my topic goal is to know this form name...
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 using the 'edit' button as you identified on post #1

Edit: and when frmFootprint is closed, the calling combo is updated anyway. so I still don't see what you are trying to achieve. I thought perhaps all the other forms that might be open than use that combo, but then you said in post #14 in response to Unc's question

you can have many forms open- Not really, one at time ex: (B1A1 open, B2A2 closed) or visa versa
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 01:58
Joined
Sep 21, 2011
Messages
14,310
We dont know which the form name called formC... since formC is opened from combobox. And my topic goal is to know this form name...

Does it require extra work from user? User must to enter a wrong item to trigger NotInList event?
No. The user must enter an item that is not in the list, hence the name of the event.
That is carried over to the data entry form, so you are making life easier for them, not harder.
 

Babycat

Member
Local time
Today, 07:58
Joined
Mar 31, 2020
Messages
275
So if you open FormC in dialog mode, you need to close that to get back to the calling form and then requery the combo?
Yes, it is exactly what i want.
 

Babycat

Member
Local time
Today, 07:58
Joined
Mar 31, 2020
Messages
275
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)?
 

ebs17

Well-known member
Local time
Today, 02:58
Joined
Feb 7, 2020
Messages
1,946
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:

Babycat

Member
Local time
Today, 07:58
Joined
Mar 31, 2020
Messages
275
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
 

ebs17

Well-known member
Local time
Today, 02:58
Joined
Feb 7, 2020
Messages
1,946
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.
 

Babycat

Member
Local time
Today, 07:58
Joined
Mar 31, 2020
Messages
275
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 01:58
Joined
Sep 21, 2011
Messages
14,310
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. :(
 

Babycat

Member
Local time
Today, 07:58
Joined
Mar 31, 2020
Messages
275
I attached the sample db here, for easy evaluate the issue
Example.png
 

Attachments

  • Example.accdb
    988 KB · Views: 64

Gasman

Enthusiastic Amateur
Local time
Today, 01:58
Joined
Sep 21, 2011
Messages
14,310
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?
 

Babycat

Member
Local time
Today, 07:58
Joined
Mar 31, 2020
Messages
275
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 01:58
Joined
Sep 21, 2011
Messages
14,310
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? :(
 

CJ_London

Super Moderator
Staff member
Local time
Today, 01:58
Joined
Feb 19, 2013
Messages
16,616
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
 

moke123

AWF VIP
Local time
Yesterday, 20:58
Joined
Jan 11, 2013
Messages
3,920
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

  • NIL.accdb
    672 KB · Views: 48
Last edited:

moke123

AWF VIP
Local time
Yesterday, 20:58
Joined
Jan 11, 2013
Messages
3,920
I need to know the calling form to requery the combo on it.

Try putting a requery in the "On Enter" event of the comboboxes.

Code:
Private Sub Cbx_Footprint_Enter()
Me.Cbx_Footprint.Requery
End Sub
 
Last edited:

Users who are viewing this thread

Top Bottom