Outlook Dropdown menus

J

Jason Meyer

Where could I find some docs/tutorials about how to populate dropdown boxes
from a SQL server DB? Basically I need some ideas/help on the best way to
connect to my SQL server and how to push that info to the dropdown.TIA


Jason
 
P

Patricia Cardoza - [MVP Outlook]

I take it the drop down is in a form? You can use an ADO connection to
connect to your SQL Server database. Then use the .AddItem method of a combo
box to add all of the items in your recordset to the object variable
assigned to your combo box.

Set objComboBox =
Item.GetInspector.ModifiedFormPages("PageName").Controls("ComboBoxControlNam
e")

While Not objRST.EOF
objComboBox.AddItem objRst.Fields("FieldName")
objRST.MoveNext
Wend

etc...post back if you need further assistance.

--
Patricia Cardoza
Outlook MVP

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***
 
J

Jason Meyer

Thanks for the info Patricia. I pretty much am a newbie to vbscript so its
pretty slow going sometimes but I will let you know if I have any other
problems.

Jason
 
J

Jason Meyer

Ok again newbie here but just having a hard time building a dsn-less
connection to my SQL server here is what I have..obviously with the uid/pwd
fields x'ed out and part of the IP.

set objCON = Server.CreateObject("ADODB.CONNECTION")

objCON.Open "Driver={SQL Server}; Server=204.169.249.XXX
address=204.169.249.XXX,1433 network=DBMSSOCN; database=RAHSCals; uid=XXX;
pwd=XXX"

When I run the form I get a script error "Object required:'Server' Line No:7

Line 7 is the set objCON = server....

So I am pretty confused as this is pretty much the same (most likely very
crappy) method i have used in other vbscripts I have been playing with to
teach myself. Is there something else that I am missing?Thanks for the help.

Jason
 
P

Patricia Cardoza - [MVP Outlook]

I usually just use

set objCON = CreateObject("ADODB.Connection")

I leave out the Server keyword.

--
Patricia Cardoza
Outlook MVP

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***
 
J

Jason Meyer

Patricia, ok sorry but I am going to bet that this will be the second to
last post I ask of you. I must be just missing something, could you take a
look at the code and help me where I am going wrong. The only error is get
is just the same script error box but the only text in it is line no:18...no
other text. Thank you for all your help


Dim objComboBox

Dim objRST

Dim objCON

Dim strSQL

'Need to figure out how to build the connection to w2k-sql with a DSN-less
connection

set objCON = CreateObject("ADODB.CONNECTION")

objCON.Open "Driver={SQL Server}; Server=204.169.249.5
address=204.169.249.5,1433 network=DBMSSOCN; database=RAHSCal; uid=rahscal;
pwd=rahscal"

set objRST = CreateObject("ADODB.RECORDSET")





strSQL = "select * from facilities;"

objRST.Open strSQL, objCON

'Events is the name of the page, cmbPlace is the name of the ComboBox I want
to populate

'Place is the name of the Field in the table of the DB I am accessing.

(line18)Set objComboBox =
Item.GetInspector.ModifiedFormPages("Events").Controls("cmbPlace")

While not objRST.EOF

objComboBox.AddItem objRST.Fields("Place")

objRST.MoveNext

Wend



Jason
 
P

Patricia Cardoza - [MVP Outlook]

Ok, so cmbPlace is the name of your combo box right? Not the name of the
field? If you choose properties of the combo box, look at the name on the
first tab of the properties dialog box.

--
Patricia Cardoza
Outlook MVP

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***
 
J

JoeyTMann

Yeah it is.

Jason
Patricia Cardoza - said:
Ok, so cmbPlace is the name of your combo box right? Not the name of the
field? If you choose properties of the combo box, look at the name on the
first tab of the properties dialog box.

--
Patricia Cardoza
Outlook MVP

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***
connection of
Item.GetInspector.ModifiedFormPages("PageName").Controls("ComboBoxControlNam
 

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