Setting a combo Rowsource from SQL server - using DSNLess connection

S

Santiago Gomez

Hello,
I am trying to set the rowsource of a combo box. I want to use a query from
the SQL Server.
I can do it if the tables are linked through ODBC, but I want to create a
DSNless connection (I think that's what it is called) so that the user does
not have to enter a password.

I get an error that says:
The record source 'SELECT * from tblProjects;' SPECIFIED ON THIS FORM OR
REPORT DOES NOT EXIST.

Thanks in advance...

here's the code I'm using.


Public Sub SetDropdownRowSource2()
Dim strSQL As String

'*************** OPEN CONNECTION TO SQL SERVER
Dim cnn As ADODB.Connection
Dim strConn As String
Set cnn = New ADODB.Connection
strConn = "Driver={SQL
Server};Server=10.33.0.33;Database=Pubs;Uid=sa;Pwd=*****;"
With cnn
.Open strConn
.CursorLocation = adUseClient
End With
'****************** END CONNECTION

strSQL = "SELECT * from tblProjects;"

Forms!frmMain.cmbSelectProject.RowSource = strSQL
End Sub
 
C

Cindy M -WordMVP-

Hi Santiago,
I am trying to set the rowsource of a combo box. I want to use a query from
the SQL Server.
This is a Word VBA newsgroup, so I have to assume you're asking this question
in respect to a Word UserForm. The form comboboxes used in the Word (or
Powerpoint) environment do not support combobox headers. Period. You can do
this in Excel (and Access, I believe).

Since you apparently have this working for some application, you need to take
your question to a group for that application.
I can do it if the tables are linked through ODBC, but I want to create a
DSNless connection (I think that's what it is called) so that the user does
not have to enter a password.

I get an error that says:
The record source 'SELECT * from tblProjects;' SPECIFIED ON THIS FORM OR
REPORT DOES NOT EXIST.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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