Populate custom form from SQL DB

G

Guest

I am new to VBA/Outlook development and am trying to populate a dropdownlist in my custom form with data that is in a SQL DB. I haven't been able to find any resources helping to explain HOW to do this (with examples). Some sample code would REALLY be appreciated as well as any other help that anyone can offer. Thanks much!
 
K

Ken Slovak - [MVP - Outlook]

There's a lot of database/Outlook information and sample code at
http://www.slipstick.com/dev/database.htm

The idea with a ComboBox would be to take the recordset you have,
iterate it and use the AddItem method of the ComboBox to add each item
in the recordset to the control. To do it in one step you would
populate a Variant array from the recordset and use the List property:
ComboBox1.List() = MyArray




Brian said:
I am new to VBA/Outlook development and am trying to populate a
dropdownlist in my custom form with data that is in a SQL DB. I
haven't been able to find any resources helping to explain HOW to do
this (with examples). Some sample code would REALLY be appreciated as
well as any other help that anyone can offer. Thanks much!
 
S

Sue Mosher [MVP]

Or, even easier, return a RecordSet with only the fields you want to include in the list, then set the Column property of the list to myRecordSet.GetRows. Listing 23.6 in my book shows the details; sample code available at http://www.outlookcode.com from the 'get the code' link.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top