View Full Version : Solved: Double Click Listbox
SparrowHawk
09-25-2005, 03:15 AM
Hello,
This is a really simple question - once upon a time I knew the code but I have completely forgotton how to do this. http://vbaexpress.com/forum/images/smilies/banghead.gif 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
Norie
09-25-2005, 07:37 AM
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
SparrowHawk
09-26-2005, 08:49 AM
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?:dunno
Thanks,
Ken
chocobochick
09-26-2005, 09:37 AM
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
Norie
09-26-2005, 10:43 AM
chocobochick
I think you may be right. :doh: :doh:
SparrowHawk
09-26-2005, 01:13 PM
Thank both of you ... with the quotes the syntax is right and everything works the way I wanted.
Another simple task solved. :friends:
Ken
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.