Arthur Fuller
artful at rogers.com
Mon Mar 17 08:02:00 CST 2003
When opening form3, pass a string such as "form1" or "form2" in OpenArgs. In Form3's OnOpen, examine the OpenArgs and do something like this: With Me If Not IsNull(.OpenArgs) Then If .OpenArgs = "form1" Then .RequestID = Forms("form1").RequestID Else .RequestID = Forms("form2").RequestID End If End If End With (Caution: compiled with Outlook.) A. -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com] On Behalf Of Hollis,Virginia Sent: March 17, 2003 8:46 AM To: 'stuart at lexacorp.com.pg'; 'accessd at databaseadvisors.com' Subject: RE: [AccessD] One form for all What do I do if it is a new record they are adding to Form 3? When a new record is added using Form 3, the RequestID (FK) shows 0. I need it to enter the same RequestID as the opening form, whether it is Form 1 or Form 2. Form 3 needs to open and set the FK - (RequestID in Table 2) to the same RequestID (PK in Table 1) as in Form 1 or Form 2. Virginia -----Original Message----- From: Stuart McLachlan [mailto:stuart at lexacorp.com.pg] Sent: Monday, March 17, 2003 7:10 AM To: Hollis,Virginia; accessd at databaseadvisors.com Subject: Re: [AccessD] One form for all > Form 1: A form that is used for requesting services - a data entry > form. Form 2: Used by the engineer to edit, update data from the > request. Form 3: Additional data form needed to open for the User & > Engineer > > The table has a RequestID as the PK > A second table is used to store additional data, with the RequestID as > FK. > > I need Form 3 to open from either Form 1 or Form 2. How do I set the > RequestID FK to the PK RequestID on Form 3? I placed the FK on Form 3 > and set the default to =Forms!Form1.RequestID. Of course this will not > work on Form 2 because the default value for RequestID references Form > 1. > > I do not want to create multiple forms to do the same thing - but if > that is > the only choice I will. How can I have Form 3 open from Form 1 &/or > Form 2 and set the RequestID? > Set Form3 recordsource to the Table2 and filter the form 1. In the Sub in Form1 and Form2 that opens Form3: DoCmd.OpenForm "Form3", , , "RequestID = " & request_ID Or: Use OpenArgs: In Form1 and 2 DoCmd.OpenForm "Form3", , , , , , Request_ID In Form3 Private Sub Form_Open(Cancel As Integer) Me.Filter = "RequestID = " & OpenArgs Me.FilterOn = True End Sub -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com