Hello all, and thanks in advance for any help you can provide. I’ll try to make this as short as possible, but I think that’s impossible
I am a fairly novice Access/MS Visual Basic programmer and have what I imagine, is a very simple problem that I just cannot figure out. I have spent many hours trying different methods to achieve what I want to do, but with no success. Hopefully one of you genius’s can point me in the right direction. Among other objects, here’s what I have and what I am trying to do. For reference, attached is a PDF file with images of my database’s design. Tables and forms are in bold, and fields are underlined:
pg1.pdf pg2.pdf pg3.pdf pg4.pdf
I have a form named ‘OrdersF’ which is linked to two tables, ‘OrdersT’ and ‘CustomersT’. The ‘OrdersF’ form stores everything in the ‘OrderT’ table. The ‘Customer’ field on the ‘OrdersF’ form gets its value (lookup) from the from the ‘Customer’ field in the ‘Customers’ table and stores it in the ‘OrdersT’ table’s ‘Customer’ field as a text object, NOT as a number from the ‘CustomersT’ table’s key field ‘ID’.
On the ‘OrdersF’ form I have another unbound Combo Box control named ‘FilterForCustomer’ that looks up all customers from the ‘Customers’ table and sets its value to whichever customer is selected. In the ‘AfterUpdate’ event in this Combo Box’s properties, I have added the following code:
DoCmd.ApplyFilter , Customer = FilterForCustomer
The function that I wish to happen is that, after selecting a specific customer in the ‘FilterForCustomer’ combo box, the value in that field is immediately used (that’s why the code is in the AfterUpdate event) to filter/display just the records in which the ‘Customer’ field’s values equals the customer that is displayed in the ‘FilterForCustomer’ field.
The ‘OrdersT’ table will eventually have thousands of entries in it and scrolling through tons of records to find one with the correct customer in it so that you could select ‘Filter by Selection’ would take too long, and selecting ‘Filter for:’ requires you to type in the name exactly correct. I like the way that the Combo Box works, where you just start typing and it tries to display the closes match from what you have typed so far. This method is quick and avoids mistakes.
The problem that I am having is that after the code is run, the filter doesn’t respond correctly and filters out all records. In the attached screen shots, you can see what I mean. I have tried using macros, tried using full syntax in object names, and a number of other experiments, but am still stuck. Can any of you help me get this resolved? I would really appreciate any advice.
Thanks,
John Wells