Solved

return records from double click in listbox

Posted on 2008-06-25
1
282 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 500 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

705 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