Wrox Programmer Forums
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 11th, 2006, 08:05 PM
Registered User
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Linking an unbound subform

I know this is probably not the best plan, but I need to link an unbound subform to some values contained in a listbox selection on the main form. The reason why I am using an unbound subform is that I want to control how the user adds/edits/navigates the records (using proper command controls).

I would like to link the subform programmatically to the main form (or the values selected in the list box). Based on the list box selection (and the values of Column(0) and Column(3)), the subform should be populated with the records from a table (tblOptions) containing fields with values equal to Column(0) and Column(3) (on the subform, it corresponds to txtExecID and txtCode).

I am currently doing this in DAO; I tried a few different things but none work.

Old September 13th, 2006, 12:27 PM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

Don't quote me, but I think a Master/Child link on a form/subform will only take one column.

Double click the subform in design view and select the data tab, then select the Master and Child fields you want to use.

You alternative is to code this OR use a query with criteria that look to the controls on your main form.

So the query behind your subform with have this as criteria for txtExecID:

And the txtCode field in the query would have this criteria:

For both of these, they may be referencing columns in the text box or combo box you are using.

The thing is, doing it this way means that only records that satisfy both field values will be returned.

Do you have more info?


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subform linking problem JimTate BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 0 April 22nd, 2008 11:07 AM
filtering records on subform from an unbound combo jd_erd Access 3 February 12th, 2007 11:21 PM
unbound field in subform chacquard Access VBA 4 February 7th, 2007 10:01 AM
Filter Subform B Based on Field in Subform A SerranoG Access VBA 3 June 18th, 2004 12:23 AM
Linking Subform using ADO Skharva Access 1 January 13th, 2004 12:27 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.