Using a pop-Up form for different forms

Tiger955

Registered User.
Local time
Today, 20:32
Joined
Sep 13, 2013
Messages
140
Hi,

I would like to use a pop-up form from different forms and need to get the name of the form from which the pop-up has been opened.

The purpose is, that when closing the pop-up again I need to requery this form.

As I need further two values as Openargs for the pop-up I tried this:

From the form I open the pop-up form (called "frmEmployee") and generate the Openargs.

Code:
Private Sub Employee_Click()
Dim strOpenargs As String
On Error Resume Next
strOpenargs = "Forms!frmBestellungenTage!" & Screen.ActiveForm.Form.Name & ".Form"
Debug.Print strOpenargs
DoCmd.OpenForm "frmEmployee", , , , , , Me.BesttagID & ";" & strOpenargs
End Sub

My problem is that I start the code from a subform and I cannot get name of the control, holding the subform.

Screen.ActiveControl.Form.Name.. brings me null
Screen.ActiveControl.Form... brings an error
Screen.ActiveForm.Name...brings the name of the subform

I need to know the forms name for the requery of the form I started from in the pop-up.

The code in the pop-up looks like this:
Code:
Private Sub Employee_AfterUpdate()
Dim strSQL As String
strSQL = "UPDATE tblBestellungstage set WPID = " & Me.Employee.Column(0) & " WHERE BesttagID = " & CLng(strValue) & ";"
'Clng(strValue) is the first part of the Openargs, this works!
 
Call SQL_PassThrough(strSQL)
DoCmd.Requery (strFormName)  
 
DoCmd.Close acForm, Me.Name
End sub

'"strFormName" should be the second part of the Openargs, which allows to requery the form, from which the pop-up was opened - this I cannot solve, this should be something like
"Forms!frmBestellungenTage!frmBestellungenTagMinusEins.Form.Requery" without the requery, as this comes from the Docmd.Requery(...)


I would appreciate any help on this!
Thanks
Michael
 
Last edited:
Open the form with the parameter "acDialog", then you code stops in the calling form and then you can requery the form afterwards, so no need for using the Openargs
Code:
DoCmd.OpenForm "frmEmployee", , , , , acDialog
 
HOW does the form from which I opened the pop-up REQUERY??
HOW can I name this form in the requery? That was the question.

Maybe to make it more clear.

I open my "frmEmployee" (my pop-Up form) on time from FormA and another time from FormB.

In the Employee_AfterUpdate-event where I set the employee to a certain field in the SQL-table I would like to REQUERY the respective form, which is either FormA or FormB, when I am still in my "frmEmployee".

Meaning, I need to find out, from which form I opened the "frmEmployee" to build my requery command

DoCmd.Requery("FormName_from_which_I_opened_frmEmployee")
 
Last edited:
HOW does the form from which I opened the pop-up REQUERY??
HOW can I name this form in the requery? That was the question.

Do the requery in the form from where you call the popup form, (remove the requery in your popup form). As I wrote the code stops running in the calling form, until you close the popup form.
Code:
Private Sub Employee_Click() 
On Error Resume Next 
DoCmd.OpenForm "frmEmployee", , , , , acDialog 
'Set in the requery here 
End Sub
 
Thanks, now I got it!

acDialog make the code wait for execution as long the pop-up is opened!

Thanks your help!
 

Users who are viewing this thread

Back
Top Bottom