p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Set a combo box list through VB


Message #1 by "Carl Schwarcz" <carl@s...> on Sat, 9 Jun 2001 18:09:02 -0700
I've got a form field whose value is set in my VB code.



I would like to set up a combo box whose contents is set based on the

field value in a complicated query.  I can certainly put the query code

in my above mentioned VB code, but I can't see how I place the contents

in the combo box list.  Can somebody point me tin the right direction?









Message #2 by "John Ruff" <papparuff@c...> on Sun, 10 Jun 2001 08:14:23 -0700
Set the RowSource of the combo box to the name of the query or the SQL

statement of the query.



For example:



Combo1.RowSource="SELECT DISTINCTROW tbl_ShopOrders.ORDER_NO FROM

tbl_ShopOrders GROUP BY tbl_ShopOrders.ORDER_NO;"



or



Combo1.RowSource= "YourQueryName"



John Ruff - The Eternal Optimist :)

 -----Original Message-----

From: 	Carl Schwarcz [mailto:carl@s...]

Sent:	Saturday, June 09, 2001 6:09 PM

To:	Access

Subject:	[access] Set a combo box list through VB



I've got a form field whose value is set in my VB code.



I would like to set up a combo box whose contents is set based on the

field value in a complicated query.  I can certainly put the query code

in my above mentioned VB code, but I can't see how I place the contents

in the combo box list.  Can somebody point me tin the right direction?


















Message #3 by "Carl Schwarcz" <carl@s...> on Sun, 10 Jun 2001 10:38:16 -0700
Thanks, John



I actually figured that out last night.  When I click on the combo box

though, it isn't populated with a list.  Instead I see the query string.

Any suggestions?  Is there something I need to do to cause the combo box

to refresh and evaluate the query?  My code runs from an event from

another combo box results in the calculation of RateTableID.  Here's a

snippet of my code:



' after code to determine applicable RateTableID value ...

strActivity = "SELECT tblRate.RateTableId, tblRate.activityID,

tblActivityCodes.name, tblRate.rate  " & _

            "FROM tblActivityCodes INNER JOIN tblRate ON

tblActivityCodes.ActivityID = tblRate.activityID  " & _

            " WHERE (((tblRate.RateTableId)=" & RateTableID & " ));"

With Me!cmbActivity

    .RowSource = strActivity

    .ColumnCount = 4

End With

------------------------------------------------------



-----Original Message-----

From: John Ruff [mailto:papparuff@c...] 

Sent: Sunday, June 10, 2001 8:14 AM

To: Access

Subject: [access] RE: Set a combo box list through VB





Set the RowSource of the combo box to the name of the query or the SQL

statement of the query.



For example:



Combo1.RowSource="SELECT DISTINCTROW tbl_ShopOrders.ORDER_NO FROM

tbl_ShopOrders GROUP BY tbl_ShopOrders.ORDER_NO;"



or



Combo1.RowSource= "YourQueryName"



John Ruff - The Eternal Optimist :)

 -----Original Message-----

From: 	Carl Schwarcz [mailto:carl@s...]

Sent:	Saturday, June 09, 2001 6:09 PM

To:	Access

Subject:	[access] Set a combo box list through VB



I've got a form field whose value is set in my VB code.



I would like to set up a combo box whose contents is set based on the

field value in a complicated query.  I can certainly put the query code

in my above mentioned VB code, but I can't see how I place the contents

in the combo box list.  Can somebody point me tin the right direction?


  Return to Index