Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a dropdown list that is populated from SQL DB

Status
Not open for further replies.

esengul

Instructor
Dec 9, 2004
59
US
HI
I am trying to create a form in MS word. i want to have a drop downlist that is populated (automaticly) from a table that is in the SQLDB. That form will be used everybody.
I am having problem with setting my connection.
here is my code so far....
======
Dim rs As DAO.Recordset
Dim str As String
Dim con As DAO.connection

Set con = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=EMUT;Data Source=NDSQLRPTP01;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation Use Encryption for Data=False;"
str = "SELECT * FROM ContactRoleDetail"
Set rs = con.OpenRecordset(str, dbOpenDynaset)

I am getting compile error message : Type mismatch
Could you tell me what i am doing wrong?
Thanks in advance
 
Hi all Again
I fixed it here is my code
======
Dim rs As ADODB.Recordset
Dim str As String
Dim Con As ADODB.Connection
Set Con = New ADODB.Connection
With Con
.CursorLocation = adUseClient
.Mode = adModeRead
.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Integrated Security=SSPI;Persist Security " & _
"Info=True;Initial Catalog=EMUT;Data Source=NDSQLRPTP01;"
.Open
End With
Set rs = New ADODB.Recordset
str = "SELECT * FROM ContactRoleDetail"
With rs
Set .ActiveConnection = Con
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open str, , , , adCmdText
End With
=====
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top