selected record in listbox

  • Thread starter Thread starter seeker
  • Start date Start date
S

seeker

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
 
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
 
Back
Top