![]() | |
#11
| |||
| |||
|
|
On 23/02/2011 17:34:22, imb wrote: Hi ; thanks for your ideas. I am sure they are correct and I am sure I am doing something wrong. I tried both methods: DoCmd.OpenForm "Form2", , , , , , ptid --> this opened up the parameter input from query2 (from the second listbox) I am trying to pass the value without the parameter input opening. Hi Tony, There are several ways. For bound forms Marsh suggestion is probably the best in using strWhere. An example of using OpenArgs in an unbound form is, by including this line in the OnOpen event of Form2: Me.RecordSource = SELECT * FROM This_table WHERE CustomerId = & Me.OpenArgs Imb Try Private Sub List0_DblClick(Cancel As Integer) * * If Not IsLoaded("Form2") Then * * * * DoCmd.OpenForm "Form2" * * End If * * DoCmd.SelectObject acForm, "Form2" * * If Nz(List0) = 0 Then * * * * DoCmd.GoToRecord acForm, "Form2", acNewRec * * Else * * * * DoCmd.GoToControl "CustomerID" * * * * DoCmd.FindRecord List0 * * End If End Sub This is a useful function to find if a form is already open Function IsLoaded(ByVal strFormName As String) As Integer ' ' Returns True if the specified form is open in Form view or Datasheet view. * * Const conObjStateClosed = 0 * * Const conDesignView = 0 If If SysCmd(acSysCmdGetObjectState, acForm, strFormName) conObjStateClosed Then If Forms(strFormName).CurrentView <> conDesignView Then * * * * * * IsLoaded = True * * * * End If * * End If End Function This can be useful after updating Form2 for with a new record to get the lis or combo box in form1 to show the new details Private Sub Form_AfterUpdate() * * If IsLoaded("Form1") Then * * * * If Nz(Forms!Form1!List0) = 0 Then * * * * *' Empty * * * * * * Forms!Form1!List0 = 0 * * * * * * Forms!Form1!List0.Requery * * * * * * Forms!Form1!List0 = CustomerID * * * * End If * * End If End Sub Phil- Hide quoted text - - Show quoted text - |
#12
| |||
| |||
|
|
The user double clicks on the record they want to see details for. On that event the second form (Form2) opens up and only the selected record (from Form1) should show up. The Form2 is based on a query that has a parameter for the id field. |
#13
| |||
| |||
|
|
Tony_E <bluestealt... (AT) hotmail (DOT) com> wrote innews:3305f496-3566-4178-9443-dd1a081bb934 (AT) j35g2000prb (DOT) googlegroups.co m: The user double clicks on the record they want to see details for. *On that event the second form (Form2) opens up and only the selected record (from Form1) should show up. *The Form2 is based on a query that has a parameter for the id field. You're making life entirely too difficult for yourself. Get rid of the parameter in the detail form. And just pass the WHERE clause in the DoCmd.OpenForm. That's the built-in way Access was designed to do this. It's the easy way. Just use it -- I can't see any reason why you should have a parameter defined in the targetted form's recordsource, nor why you should get into the complexities of using the form's OpenArgs parameter. Access was designed from the beginning to make it easy to open a form with a specific record loaded. Use that design to make your life easier. -- David W. Fenton * * * * * * * * *http://www.dfenton.com/ contact via website only * *http://www.dfenton.com/DFA/ |
![]() |
| Thread Tools | |
| Display Modes | |
| |