Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
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 May 17th, 2007, 04:07 AM
Registered User
Join Date: Mar 2007
Location: Fresno, CA, .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combo Box dependent transferred to another form


I have a situation in developing an access form, that I need to display the values from a record as the selected values in the dependent combo boxes. This I could do on the web with ASP code but this is my first time building an access form as according to the higher powers I cannot host anything on the web, so I have to create a vb - access frontend that can be shared on a network drive.

I would really appreciate any help.

Old May 17th, 2007, 12:50 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

Hi, this is pretty common.

Create a module and declare some public variables. Since these are combo boxes, I am going to assume they are bound to PKs, so the public variable should be integers.

Public pCombo1, pCombo2, pCombo3 As Integer

Now these are available throughout your VBA without declaration.

When you move from the first form with your selections to your second form with combo boxes (already made up and displaying meaningful fields) then do this on the first form's button's on click event:

pCombo1 = Me.SelectedField
pCombo2 = Me.NextSelectedField

etc, or where ever they are coming from. If they are not integer values, then you will need to modify the code accordingly.

Then on the On Load or On Open event of the second form, put this code:

Me.Combo1 = pCombo1
Me.Combo2 = pCombo2

Of course, on the first form you will want to make sure that each filed has a value to pass, otherwise substitute another value.

Does this get you started?


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Form and Combo Box Leave Trails on Screen Coby Excel VBA 4 August 4th, 2007 01:54 AM
Retain form value from dependent list box qhong Dreamweaver (all versions) 18 November 4th, 2004 03:36 AM
Drop Down/Combo box/List in a Form from DB mazimi Classic ASP Basics 2 October 1st, 2004 10:43 AM

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