Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 26th, 2006, 10:14 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Combobox List

I am using VBA, not VB to generate dynamic combobox list. The three combobox list come from the three columns of a Access table by using SQL select DISTINCT....

Intension: After all the list are populated, user is able to select from one of the combobox. Once the user select the item, the list in the other two are changed according to the relationship in the Access table. Otherwise, the user could make the combination which does not exist in the database. Do you have any idea how to do this? 1) I was thinking of using first combo_change to control the list of other two, but it mess up the combobox list when I do combo.clear.

2) how to control the list of other two? Shall I still open the database to run SQL again?

Any thoughts are grateful. Thank you very much.

Reply With Quote
  #2 (permalink)  
Old June 27th, 2006, 02:55 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The SQL in Access is pretty well integrated into the sytem. You can put many things into your SQL that would not fly outside Access.

One thing you can do is put calls into the SQL of functions existing in modules in the DB:
Code:
SELECT MyFunc(tbl!Fld), tbl!Fld
FROM tbl;
The DB system is optimized so that if the function receives no arguments, or receives a constant, the function is run only once, and the answer is stored, being inserted into each row of the output.
But if the function receives a variable argument (such as the contents of a field), the function will be run once per row.
If you wrote a function that read the value of combo 1, you could then call that function from the WHERE clause of the query that is the rowsource for combo 2. (You could build in a default value of, say -1 for cases where combo 1 is empty.)
Then the Change event of combo one could run cboTwo.Requery.
This way, combo two tends to its own business (with a little help from a User-Defined function).
Reply With Quote
  #3 (permalink)  
Old June 29th, 2006, 09:41 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much, BrianWren, haven't got chance to try your method as I finally come up the solution of using code to generate Pivot table, and use the output to call other functions. Thanks again.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combobox List Fill Range jani Access VBA 1 July 29th, 2008 05:04 PM
Dynamic combobox using DB ulash JSP Basics 0 August 29th, 2007 08:43 AM
list of values from postgresql to combobox zamir4eva Beginning PHP 1 January 3rd, 2007 11:29 PM
"Are you Sure" Before Dropping List in ComboBox lam2rw Excel VBA 2 September 22nd, 2006 06:57 AM
Combobox that shows what's not in its list Mitch Access 6 September 18th, 2003 11:00 AM



All times are GMT -4. The time now is 02:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.