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
|
|||
|
|||
selected record in listbox
I have a listbox on a form. When the vbkeyreturn occurs the following code
runs: Private Sub lbxNameSearch_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then Forms!frmchecks.TRA_TOWHOM = DLookup("[tra:towhom]", "transactions", "[tra:towhom] = '" & Me.lbxNameSearch.ItemData(Me.CurrentRecord) & "'") Forms!frmchecks.TRA_TOWHOM2 = DLookup("[tra:towhom2]", "transactions", "[tra:towhom] = '" & Me.lbxNameSearch.ItemData(varItem) & "'") Forms!frmchecks.TRA_TOWHOM3 = DLookup("[tra:towhom3]", "transactions", "[tra:towhom] = '" & Me.lbxNameSearch.ItemData(varItem) & "'") DoCmd.Close acForm, "frmnamesearch" End If I am using dlookup to capture the data piece but instead of capturing the selected record it transfers the first record in the list to the other form. How do I get the selected records data to transfer? Thanks |
#2
|
|||
|
|||
selected record in listbox
seeker,
You should have the record source for your second form set to the "transitions" table or a query that returns records from that table. Then use the "On Double Click" event of your list box to run the following statement: Docmd.OpenForm, "NameOfYourForm", ,"[tra:towhom] = Me.lbxNameSearch" For more info on open the form to a specific record, look in the Help file. ----- HTH Mr. B http://www.askdoctoraccess.com/ Doctor Access Downloads Page: http://www.askdoctoraccess.com/DownloadPage.htm "seeker" wrote: I have a listbox on a form. When the vbkeyreturn occurs the following code runs: Private Sub lbxNameSearch_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then Forms!frmchecks.TRA_TOWHOM = DLookup("[tra:towhom]", "transactions", "[tra:towhom] = '" & Me.lbxNameSearch.ItemData(Me.CurrentRecord) & "'") Forms!frmchecks.TRA_TOWHOM2 = DLookup("[tra:towhom2]", "transactions", "[tra:towhom] = '" & Me.lbxNameSearch.ItemData(varItem) & "'") Forms!frmchecks.TRA_TOWHOM3 = DLookup("[tra:towhom3]", "transactions", "[tra:towhom] = '" & Me.lbxNameSearch.ItemData(varItem) & "'") DoCmd.Close acForm, "frmnamesearch" End If I am using dlookup to capture the data piece but instead of capturing the selected record it transfers the first record in the list to the other form. How do I get the selected records data to transfer? Thanks |
Thread Tools | |
Display Modes | |
|
|