![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello; Access 2000. *I have two forms, each form has one listbox. Form1 opens and the listbox displays all the data from a table (it is based on a query called query1). 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. I have to this point been able to code an event that captures the value of the id field of the selected row and pass it into a variable. *I just can't get that value to automatically pass into the parameter of query2 in Form2. *What happens is the parameter input opens up and I still have to manually type in the value. How do I make happen programatically? Here is the code: * *Private Sub List0_DblClick(Cancel As Integer) * * * 'open a form and pass whatever baseid was double clicked * * * 'to the parameter of the query the form is built off of * * * Dim ptid As Integer * * * ptid = Forms!Form1!List0.Column("0") * * * MsgBox ("the value is" & ptid) * * * DoCmd.OpenForm "Form2", acNormal * *End Sub |
#3
| |||
| |||
|
|
Hello; Access 2000. *I have two forms, each form has one listbox. Form1 opens and the listbox displays all the data from a table (it is based on a query called query1). 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. I have to this point been able to code an event that captures the value of the id field of the selected row and pass it into a variable. *I just can't get that value to automatically pass into the parameter of query2 in Form2. *What happens is the parameter input opens up and I still have to manually type in the value. How do I make happen programatically? Here is the code: * *Private Sub List0_DblClick(Cancel As Integer) * * * 'open a form and pass whatever baseid was double clicked * * * 'to the parameter of the query the form is built off of * * * Dim ptid As Integer * * * ptid = Forms!Form1!List0.Column("0") * * * MsgBox ("the value is" & ptid) * * * DoCmd.OpenForm "Form2", acNormal * *End Sub |
#4
| |||
| |||
|
|
On Feb 23, 4:01 pm, Tony_E <bluestealt... (AT) hotmail (DOT) com> wrote: Hello; Access 2000. I have two forms, each form has one listbox. Form1 opens and the listbox displays all the data from a table (it is based on a query called query1). 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. I have to this point been able to code an event that captures the value of the id field of the selected row and pass it into a variable. I just can't get that value to automatically pass into the parameter of query2 in Form2. What happens is the parameter input opens up and I still have to manually type in the value. How do I make happen programatically? Here is the code: Private Sub List0_DblClick(Cancel As Integer) 'open a form and pass whatever baseid was double clicked 'to the parameter of the query the form is built off of Dim ptid As Integer ptid = Forms!Form1!List0.Column("0") MsgBox ("the value is" & ptid) DoCmd.OpenForm "Form2", acNormal End Sub Hi Tony, You can assign ptid to OpenArgs in the OpenForm statement, and use the value inside Form2. Imb. |
#5
| |||
| |||
|
|
Access 2000. I have two forms, each form has one listbox. Form1 opens and the listbox displays all the data from a table (it is based on a query called query1). 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. I have to this point been able to code an event that captures the value of the id field of the selected row and pass it into a variable. I just can't get that value to automatically pass into the parameter of query2 in Form2. What happens is the parameter input opens up and I still have to manually type in the value. How do I make happen programatically? Here is the code: Private Sub List0_DblClick(Cancel As Integer) 'open a form and pass whatever baseid was double clicked 'to the parameter of the query the form is built off of Dim ptid As Integer ptid = Forms!Form1!List0.Column("0") MsgBox ("the value is" & ptid) DoCmd.OpenForm "Form2", acNormal End Sub |
#6
| |||
| |||
|
|
imb wrote: On Feb 23, 4:01 pm, Tony_E <bluestealt... (AT) hotmail (DOT) com> wrote: Hello; Access 2000. *I have two forms, each form has one listbox. Form1 opens and the listbox displays all the data from a table (it is based on a query called query1). 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. I have to this point been able to code an event that captures the value of the id field of the selected row and pass it into a variable. *I just can't get that value to automatically pass into the parameter of query2 in Form2. *What happens is the parameter input opens up and I still have to manually type in the value. How do I make happen programatically? Here is the code: * Private Sub List0_DblClick(Cancel As Integer) * * *'open a form and pass whatever baseid was double clicked * * *'to the parameter of the query the form is built off of * * *Dim ptid As Integer * * *ptid = Forms!Form1!List0.Column("0") * * *MsgBox ("the value is" & ptid) * * *DoCmd.OpenForm "Form2", acNormal * End Sub Hi Tony, You can assign ptid to OpenArgs in the OpenForm statement, and use the value inside Form2. Imb. Or do a * *Docmd.Openform "YourFormName",,,"Id = " & Me.YourListBoxName.Column(0) The above assumes the first column (index starts at 0) is the key. *The Column property and ListIndex property are worth knowing.- Hide quoted text - - Show quoted text - |
#7
| |||
| |||
|
|
On Feb 23, 11:25 am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote: imb wrote: On Feb 23, 4:01 pm, Tony_E <bluestealt... (AT) hotmail (DOT) com> wrote: Hello; Access 2000. I have two forms, each form has one listbox. Form1 opens and the listbox displays all the data from a table (it is based on a query called query1). 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. I have to this point been able to code an event that captures the value of the id field of the selected row and pass it into a variable. I just can't get that value to automatically pass into the parameter of query2 in Form2. What happens is the parameter input opens up and I still have to manually type in the value. How do I make happen programatically? Here is the code: Private Sub List0_DblClick(Cancel As Integer) 'open a form and pass whatever baseid was double clicked 'to the parameter of the query the form is built off of Dim ptid As Integer ptid = Forms!Form1!List0.Column("0") MsgBox ("the value is" & ptid) DoCmd.OpenForm "Form2", acNormal End Sub Hi Tony, You can assign ptid to OpenArgs in the OpenForm statement, and use the value inside Form2. Imb. Or do a Docmd.Openform "YourFormName",,,"Id = " & Me.YourListBoxName.Column(0) The above assumes the first column (index starts at 0) is the key. The Column property and ListIndex property are worth knowing.- Hide quoted text - - Show quoted text - 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. I also tried: DoCmd.OpenForm "Form2", , , "CustomerID = " & Forms!Form1! List0.Column("0") the parameter input opened twice this time I pointed the Form2 to the query as well because earlier I got a message that the program couldn't work because the form was not built off of a table or query. I don't quite understand why I had to do that but I did it. If you can think of something else I missed please let me know. thanks so much Tony |
#8
| |||
| |||
|
|
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. |
#9
| |||
| |||
|
|
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. |
#10
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |