Reputation: 2903
I'm really just beginning creating forms in Access 2007, and I'm trying to get a form to open with customer information if I click on the Customer's name in a list box.
Here is what the lookup query is:
SELECT msm_customers_extended.id AS ID, UCase([filed_name]) AS [Customer Name], UCase([address1]) & " " & UCase([address2]) AS Address
FROM msm_customers_extended
ORDER BY UCase([filed_name]);
So I have the bound column set to "1", and the Control Source set to "Customer ID". I have a macro under the double click event set to:
Action: OpenForm Arguments:
When I test it out, I get an input box saying "Customer ID", so I'm assuming I'm not grabbing the ID from my list box. How do I get the ID from the list to link to my 2nd form that I'm trying to open?
Upvotes: 0
Views: 4409
Reputation: 25272
As bluefeet stated, you should just change your condition. Since you are using macros, not VBA, try changing the Where condition to:
[ID] = Forms!CustomerListFormName!ListBoxName
Altough macros are an excellent way to discover the properties and events of Access, I encourage you to switch to VBA as soon as you start to master the properties and events. Variables, error handling, readability, VBA will give you much more satisfaction. And don't forget that you can automatically translate your existing macros to VBA to get you started quickly.
Upvotes: 1
Reputation: 247840
Change you WHERE Condition from this:
Where Condition: [ID] = [Customer ID]
To this:
"[ID]=" & Me![Customer ID]
You have to tell it where to pull the Customer ID from. By using, the Me
you are letting it know it is from that form.
Upvotes: 0