Reference subform name from popup

Telecom

Registered User.
Local time
Today, 14:06
Joined
Oct 28, 2004
Messages
42
Hello all,

I'm trying to reference the name of my subform or form off of my popup. I'm doing this because I want to use it as a referencing point to requery the subform after I add my record on the popup form.

Forms![fpop_Location_Active_Circuits_Lines]![fsub_Active_Circuits_Lines].requery

I know I could place that exact code in my close event but I'm using this popup form off of multiple subforms and that form name could change. So when the times comes to requery that particular subform I don't know which one I should be requering.

Here is the open code I started to use on my popup form:

Dim ctlPrevious As Control
Set ctlPrevious = Screen.PreviousControl

Select Case ctlPrevious.Name

Case "Forms![fpop_Location_Active_Circuits_Lines]![fsub_Active_Circuits_Lines]"
'Declares Form Dim
MasterForm = "Forms![fpop_Location_Active_Circuits_Lines]![fsub_Active_Circuits_Lines]"

End Select

In my close event I could do this

MasterForm.requery

The problem with the PreviousControl is that on the subform I can't get it to setfocus to the subform's name. Even with these commands:

Forms![fpop_Location_Active_Circuits_Lines]![fsub_Active_Circuits_Lines].SetFocus
DoCmd.OpenForm "fpop_Admin_Circuit_Line"


Is there a way to pass on the PreviousControl name of the subform or is there a way to see if a particular form is open so I could test that for the requery.

Let me know if there is anything out there that could do this.

Thanks!!
 
I tried setting focus to the subform off the form and it's not working. The code I used to open the popup is on an AfterUpdate event on a comboBox. I use a Select Case to run specific commands based off what is selected in the comboBox.


Private Sub CommandsOptionCombo_AfterUpdate()

Dim CommandsOptionComboTest As String
CommandsOptionComboTest = Me.CommandsOptionCombo
Select Case CommandsOptionComboTest

Case "Test Admin Circuit/Line"

Forms!fpop_Location_Active_Circuits_Lines!fsub_Active_Circuits_Lines.SetFocus
DoCmd.OpenForm "fpop_Admin_Circuit_Line"
Me.CommandsOptionCombo = ""

End Select



I believe the reason it's not able to setfocus to the subform is that I'm running the command on AfterUpdate.
 
One can't set focus to the control which has focus.

If "fpop_Admin_Circuit_Line" is the Form and CommandsOptionCombo is on a subform of that for, you have to set focus to the form and them set it to the subform, and

forms!FormName!subformName.form!CommandsOptionCombo = ""

If you popup is modal, you can't move focus off it. You have to close it.
 
The .setfocus command wasn't working for me. In order for me to make one generic popup form that could be used off multiple forms and subforms here is what I ended up doing.

On my main form I have a ComboBox with a list of commands that the user can run. Listed in it is: Add, Edit, Duplicate, etc.

On AfterUpdate it would run a Select Case statement looking for the data in the comboBox. Using the code under the specific case it would open up a popup form. Previously I had one form for Adds, edits, and duplicates. All these popup forms where similiar in many cases. I wanted to create one form that could do all the listed commands. I created an invisible txtBox that would act as a counter to indicate the command I was trying to perform. Each # in the Counter would mean a specific type of command.

Dim CommandsOptionComboTest As String
CommandsOptionComboTest = Me.CommandsOptionCombo
Select Case CommandsOptionComboTest

Case "Add"
Me!TestAdminCommandCounter = 1
DoCmd.OpenForm "fpop_Admin_Circuit_Line"
Me.CommandsOptionCombo = ""

Case "Edit"
Me!TestAdminCommandCounter = 2
DoCmd.OpenForm "fpop_Admin_Circuit_Line"
Me.CommandsOptionCombo = ""

Case "Duplicate"
Me!TestAdminCommandCounter = 3
DoCmd.OpenForm "fpop_Admin_Circuit_Line"
Me.CommandsOptionCombo = ""

End Select


Once the popup form (fpop_Admn_Circuit_Line) was on Open Event it ran the following code. (It goes out sees what forms are open based on the Forms collection.)

See Attachment on the Open_Event for the popup form and the custom Procedure.

I'm sure there was another way to do this though this was all I could think of at the time.
Thanks!
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom