Consulting

Results 1 to 6 of 6

Thread: Solved: Double Click Listbox

  1. #1

    Solved: Double Click Listbox

    Hello,

    This is a really simple question - once upon a time I knew the code but I have completely forgotton how to do this. I have a listbox showing customer names. I want to be able to doubleclick on a name and have that customer's data form come up. The LB is bound to column one (hidden - primary key of customer ID)

    What is the code to do this?
    TIA
    Ken

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    You could probably use the OpenForm method of DoCmd and specify the customer ID in the where argument.

    Something like this perhaps.
    DoCmd.OpenForm [CustomerData], , ,"[CustomerID]=" & Me!cmbCustomer

  3. #3
    Thanks for your reply Norie. I don't quite follow why this is happening, but I get an error of unable to find the field "|". I changed the code to read:

    DoCmd.OpenForm [Customer], , , "[CustomerID]=" & Me!List13

    to reflect proper form names etc. CustomerID is the primary key of the customer table and the bound line. Me!List13 gives the correct primary key on a double click however. I tried redoing the docmd line but nothing seems to bring up the form without an error. Any ideas?

    Thanks,
    Ken

  4. #4
    Is "Customer" the name of the form you're trying to open? Because the way your code is written, Access might be looking for some type of control named Customer that contains a string with the table name it needs to open. Try using quotes and removing the brackets, like this:

    DoCmd.OpenForm "Customer", , , "CustomerID=" & Me!List13

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    chocobochick

    I think you may be right.

  6. #6
    Thank both of you ... with the quotes the syntax is right and everything works the way I wanted.

    Another simple task solved.

    Ken

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •