PC Review


Reply
Thread Tools Rate Thread

ComboBox_Change Event to Populate another Combox

 
 
Tobi
Guest
Posts: n/a
 
      31st Oct 2006
I have a userform that has a combobox for car makes, and I want to make
it so that when a make is selected, the box below it will be populated
with the models of that make.

I already have the makes populating the make comboboxes using ADO on
the UserForm_Initialize event.
I already have a table with all of the make/model info, there is a
column of models with a column that contains their makes, and to pull
the makes, i just SELECT DISTINCT Makes.

I tried making the ComboBox_change event connect and query the database
with the ComboBox.Text, but that causes all sorts of annnoying
ridiculously-hard-to-debug errors, and I am thinking that there must be
a smoother way to do this. Is there an event that occurs after the text
is changed and then idles? or is there a way I can make a combobox
intrinsically tied to an incomplete query, where the above box plugs
the missing link into the incomplete query and then connects and
retrieves the data?

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      31st Oct 2006
How about the Enter event of the second combobox?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tobi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have a userform that has a combobox for car makes, and I want to make
> it so that when a make is selected, the box below it will be populated
> with the models of that make.
>
> I already have the makes populating the make comboboxes using ADO on
> the UserForm_Initialize event.
> I already have a table with all of the make/model info, there is a
> column of models with a column that contains their makes, and to pull
> the makes, i just SELECT DISTINCT Makes.
>
> I tried making the ComboBox_change event connect and query the database
> with the ComboBox.Text, but that causes all sorts of annnoying
> ridiculously-hard-to-debug errors, and I am thinking that there must be
> a smoother way to do this. Is there an event that occurs after the text
> is changed and then idles? or is there a way I can make a combobox
> intrinsically tied to an incomplete query, where the above box plugs
> the missing link into the incomplete query and then connects and
> retrieves the data?
>



 
Reply With Quote
 
Tobi
Guest
Posts: n/a
 
      31st Oct 2006
I tried making a Model1_Enter event, and i get the error message:

"Compile error:
Expected user-defined type, not project"


I am not sure what to do, what I have is a function that connects to
the SQL Server via ADO, and the function takes in a SQL String as a
query, and then attempts to execute the query, and on error returns
false, so it trys and trys until the user gives a string that queries
cleanly, then returns the recordset.

Is there a comprehensive list of events in VB/VBA? I have the O'Reilly
VB/VBA in a nutshell book, and there is no list there, nor have I been
able to find one through search. I am stuck.

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      31st Oct 2006

"Tobi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I tried making a Model1_Enter event, and i get the error message:
>
> "Compile error:
> Expected user-defined type, not project"
>
>
> I am not sure what to do, what I have is a function that connects to
> the SQL Server via ADO, and the function takes in a SQL String as a
> query, and then attempts to execute the query, and on error returns
> false, so it trys and trys until the user gives a string that queries
> cleanly, then returns the recordset.



I can't really help you with as little detail as that. Compilere error,
where in the code, I'm supposed to know?


>
> Is there a comprehensive list of events in VB/VBA? I have the O'Reilly
> VB/VBA in a nutshell book, and there is no list there, nor have I been
> able to find one through search. I am stuck.



If you go into the VBIDE, and view code in the Userform. Select one of the
Combobox event procedures already there and then in the dropdown at the top
right of the code module, click on that and you see all events available for
a combobox.


 
Reply With Quote
 
Tobi
Guest
Posts: n/a
 
      31st Oct 2006
> If you go into the VBIDE, and view code in the Userform. Select one of the
> Combobox event procedures already there and then in the dropdown at the top
> right of the code module, click on that and you see all events available for
> a combobox.

Oh whoa, I totally missed that, thank you, I will more than likely be
able to figure this one out.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
populate a listbox/combox in a propertygrid at run-tim asharda@woh.rr.com Microsoft C# .NET 1 29th May 2008 01:53 PM
Combobox_change event fires when a workbooks is saved Paul W Smith Microsoft Excel Programming 3 18th May 2008 11:34 PM
Combobox_Change event fires on workbook close Geoff Microsoft Excel Programming 3 17th Dec 2007 08:30 PM
ComboBox.Clear method calling ComboBox_Change event? =?Utf-8?B?Q2xheW1hbg==?= Microsoft Excel Programming 2 1st Aug 2007 03:52 PM
Combobox_change event problem =?Utf-8?B?U2hhd24gRy4=?= Microsoft Excel Programming 2 18th Aug 2005 01:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.