Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

return records from double click in listbox

Posted on 2008-06-25
1
Medium Priority
?
285 Views
Last Modified: 2013-11-28
Hi,

I have form which has a list box on which lists all customers in the tbl_contacts table.  What i'm trying to do is allow a user to double click one of the customers in the lb and have all the data from tbl_contacts populate into the appropriate fields on the form or that customer.

The form has unbound text boxes on setup to accept data from tbl_contacts.

Hope someone can shed some light.

Regards,
Tom
0
Comment
Question by:d10u4v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
harfang earned 1500 total points
ID: 21871142
The easiest would be to use a bound form with bound controls and use the control wizard to create a combo box to "find a record on this form". The code will work the same way with a list box (change the combo to a list box after the wizard has run).

If you prefer, the snippet below shows one way to do it, provided that the list box returns the ID field of tbl_contacts.

(°v°)

Private Sub lstContacts _DblClick(Cancel As Integer)
    
    Dim strSQL As String
    
On Error Goto Problem
    
    strSQL = "Select * From tbl_contacts Where ID=" & lstContacts
    With CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
        Me.txtContactName = !ContactName
        Me.txtETC = !ETC
    End With
    Exit Sub
    
Problem:
    Me.txtContactName = Null
    Me.txtETC = Null
    MsgBox Err.Description
    
End Sub

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question