A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

selected record in listbox



 
 
Thread Tools Display Modes
  #1  
Old September 18th, 2009, 03:35 AM posted to microsoft.public.access.forms
seeker
external usenet poster
 
Posts: 133
Default 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  
Old September 18th, 2009, 12:41 PM posted to microsoft.public.access.forms
Mr. B[_4_]
external usenet poster
 
Posts: 171
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.