A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Reference the form that opened the current form



 
 
Thread Tools Display Modes
  #1  
Old February 25th, 2005, 06:17 PM
Renee
external usenet poster
 
Posts: n/a
Default 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  
Old February 25th, 2005, 06:31 PM
Renee
external usenet poster
 
Posts: n/a
Default


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  
Old February 25th, 2005, 06:44 PM
Brian
external usenet poster
 
Posts: n/a
Default

"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  
Old February 25th, 2005, 07:02 PM
fredg
external usenet poster
 
Posts: n/a
Default

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  
Old February 25th, 2005, 07:33 PM
Mark
external usenet poster
 
Posts: n/a
Default

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  
Old February 25th, 2005, 08:01 PM
Renee
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 12:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.