subform combo box
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access Training and help » Subform / combo box

Subform / combo box

resolvedResolved · High Priority · Version 2003

replyReply Thu 9 Oct 2008, 19:20Delegate Neal said...

Neal has attended:
Access Advanced course

Subform / combo box

Hi
I have a combo box that selects the country data from my table and opens a form. In the form the country data is shown in a subform. I now want to add a combo box to the form that filters the sub form data so that I only view the data for a selected town
Help
Thanks

For upcoming training course dates see: Pricing & availability

replyReply Fri 17 Oct 2008, 16:24Delegate Neal said...

RE: subform / combo box

Any luck with an answer?

replyReply Wed 29 Oct 2008, 20:10Delegate Mark said...

RE: subform / combo box

Hi Neal, note that I am delegate not a tutor but feel sure I can help.

Firstly I don't understand your first sentence. So if my guessed solutions below are not what you need then you can reply with more information such as, is your subform based directly on a table, a query or a form?

You can add a combo box into the subform and select the wizard option 'Find a record on my form based on the value I selected in my combo box'. Then select the town field and complete. You can then select from the drop down list or type in the town. You need to click out of the box for it to go. I like adding a small save or refresh button next to the drop down and put text on it saying 'Go' to make this intuitive.

Another solution if you don't mind re-inserting the subform is to choose to make the subform match a value on the main form (during the creation with the Wizard). If town is a natural ingredient of the main form and the main form is single (one record per form) then the subform will automatically go the correct town without any need to select from a combo box. Other solutions I can give depend on what the main form is based on, but options might include creating a simple small table to 'fool' the system. That table would have primary key and one field (call it SearchTown if you like), then include that table in the query that supplies the form and insert a combo box for that field. When you then create the subform you match the subform field Town to SearchTown. For the combo box (drop down list) source you insert a query to list the towns from where these are stored (using group by to list each once if needed).

replyReply Thu 30 Oct 2008, 14:59Delegate Neal said...

RE: subform / combo box

Hi Mark

Thanks for your help. Therefore I have created a Form with the fields I want to via from my query. I have named it 'subformmain'. I have then created a Form named 'Main' and have added a subform using the wizard and have selected 'subformmain'. I added a combobox using the wizard and selected the option to select a value on my form from the 'country' field. Now if I add another combobox to filter the country by 'town' again using the wizard, select a value of my form it does select the town but when I open the combobox I see all the towns in the table/query and when a twon is selected it returns all the towns for that country.

Any ideas?

Thanks

replyReply Thu 30 Oct 2008, 22:40Delegate Mark said...

RE: subform / combo box

Hello again Neal,

I'm not sure if you are putting the combos in the subform or main form. There is a 'classic' problem and answer case for twin combos to be found in text books which seem to just launch into vba code regardless. However, I often find there are ways round not having to use code.

If you can tell me if the country and town fields are in the same table, and whether or not the data behind the main part of the form is related (and how) to the subform then we may be able to get at least one of the two fields filtered by one means and the other by a different one.

Regard, Mark

 

Please browse our web site to find out more about
access+training and other Microsoft training courses.

Access tip:

Create calculated fields that work out your age

You can uset eh year function to work out the year from NOW function and then subtract it with your date of birth type field

Age=Year(Now( ))-Year([DoB])

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard