?
Solved

return records from double click in listbox

Posted on 2008-06-25
1
Medium Priority
?
283 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

777 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