If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Reference the form that opened the current form
I have one form used for editing, that can be opened by two other forms.
Since this is not a parent child relationship, is there a way to reference the form that opened the active form? Example of what I am searching for: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm1]![ID] End If End If Thank you in advance! Renee |
#2
|
|||
|
|||
Typo, sorry, should be: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm2]![ID] End If End If "Renee" wrote: I have one form used for editing, that can be opened by two other forms. Since this is not a parent child relationship, is there a way to reference the form that opened the active form? Example of what I am searching for: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm1]![ID] End If End If Thank you in advance! Renee |
#3
|
|||
|
|||
"Renee" wrote in message
... I have one form used for editing, that can be opened by two other forms. Since this is not a parent child relationship, is there a way to reference the form that opened the active form? Example of what I am searching for: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm1]![ID] End If End If Thank you in advance! Renee On the assumption that you are opening the form using OpenForm, use the OpenArgs argument to pass in either the name of the opening form or (better) the value of ID. |
#4
|
|||
|
|||
On Fri, 25 Feb 2005 10:31:04 -0800, Renee wrote:
Typo, sorry, should be: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm2]![ID] End If End If "Renee" wrote: I have one form used for editing, that can be opened by two other forms. Since this is not a parent child relationship, is there a way to reference the form that opened the active form? Example of what I am searching for: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm1]![ID] End If End If Thank you in advance! Renee Use the OpenArgs argument when you open the form: DoCmd.OpenForm "FormName", , , , , , Me.Name Then in the "FormName" Load event: If Me.OpenArgs = "Form1" Then Me.ID = Forms![form1]![ID] Elseif Me.OpenArgs = "Form2" Then Me.ID = Forms![form2]![ID] Else ' Do something else End If Why not just pass the form's [ID] field value instead of the name of the form? DoCmd.OpenForm "FormName", , , , , , Me![ID] Then in the "FormName" Load event: If Not IsNull(Me.OpenArgs) then Me!ID = Me.OpenArgs End If -- Fred Please only reply to this newsgroup. I do not reply to personal email. |
#5
|
|||
|
|||
If you want to pass the calling form's name, and you're pulling the same
field (ID) from it, you don't need to use the if..then clause: Me.ID=Forms(Me.OpenArgs)![ID] this way, it won't matter what the calling form's name is. Sometimes I end up changing form names, so I try to avoid hard-coding a name if possible. As mentioned before, if all you're trying to do is come up with the value in the ID field, then just pass that as the OpenArg. "fredg" wrote in message . .. On Fri, 25 Feb 2005 10:31:04 -0800, Renee wrote: Typo, sorry, should be: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm2]![ID] End If End If "Renee" wrote: I have one form used for editing, that can be opened by two other forms. Since this is not a parent child relationship, is there a way to reference the form that opened the active form? Example of what I am searching for: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm1]![ID] End If End If Thank you in advance! Renee Use the OpenArgs argument when you open the form: DoCmd.OpenForm "FormName", , , , , , Me.Name Then in the "FormName" Load event: If Me.OpenArgs = "Form1" Then Me.ID = Forms![form1]![ID] Elseif Me.OpenArgs = "Form2" Then Me.ID = Forms![form2]![ID] Else ' Do something else End If Why not just pass the form's [ID] field value instead of the name of the form? DoCmd.OpenForm "FormName", , , , , , Me![ID] Then in the "FormName" Load event: If Not IsNull(Me.OpenArgs) then Me!ID = Me.OpenArgs End If -- Fred Please only reply to this newsgroup. I do not reply to personal email. |
#6
|
|||
|
|||
Thank you much, that worked perfectly!
Have a great weekend, Renee "fredg" wrote: On Fri, 25 Feb 2005 10:31:04 -0800, Renee wrote: Typo, sorry, should be: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm2]![ID] End If End If "Renee" wrote: I have one form used for editing, that can be opened by two other forms. Since this is not a parent child relationship, is there a way to reference the form that opened the active form? Example of what I am searching for: If opened by frm1 Then Me.ID = Forms![frm1]![ID] Else If opened by frm2 Then Me.ID = Forms![frm1]![ID] End If End If Thank you in advance! Renee Use the OpenArgs argument when you open the form: DoCmd.OpenForm "FormName", , , , , , Me.Name Then in the "FormName" Load event: If Me.OpenArgs = "Form1" Then Me.ID = Forms![form1]![ID] Elseif Me.OpenArgs = "Form2" Then Me.ID = Forms![form2]![ID] Else ' Do something else End If Why not just pass the form's [ID] field value instead of the name of the form? DoCmd.OpenForm "FormName", , , , , , Me![ID] Then in the "FormName" Load event: If Not IsNull(Me.OpenArgs) then Me!ID = Me.OpenArgs End If -- Fred Please only reply to this newsgroup. I do not reply to personal email. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need to clear controls of Filter form | Jan Il | Using Forms | 2 | November 28th, 2004 02:04 PM |
auto entry into second table after update | Tony | New Users | 13 | July 9th, 2004 10:42 PM |
Form Doesn't Go To New Record | Steve | New Users | 15 | May 16th, 2004 04:33 PM |
Circular reference error | Linda | New Users | 3 | April 27th, 2004 04:09 AM |
Array reference from current row to bottom of column | JM | Worksheet Functions | 0 | February 26th, 2004 01:09 PM |