Fordraiders
asked on
outlook custom form with command button not executing code
Outlook 2010.
vb script editor problem/issues
Custom form
Page "Survey" (p.2)
I have a command button on a custom form.
I'm just trying the code out to see if i can get anything to execute. after pressing the command button.
I always get an error on this line:
Dim cnn As ADODB.Connection
The only thing i can get to work is simple: hello world
Sub CommandButton2_Click()
msgbox "Hello World"
End Sub
Thanks
fordraiders
vb script editor problem/issues
Custom form
Page "Survey" (p.2)
I have a command button on a custom form.
I'm just trying the code out to see if i can get anything to execute. after pressing the command button.
I always get an error on this line:
Dim cnn As ADODB.Connection
Sub CommandButton2_Click()
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
' Open a Connection using an ODBC DSN named "Pubs".
cnn.Open "ss_program_workflow", "webuser", "zwebuserprd"
' Find out if the attempt to connect worked.
If cnn.State = adStateOpen Then
MsgBox "Welcome to Pubs!"
Else
MsgBox "Sorry. No Pubs today."
End If
' Close the connection.
cnn.Close
End Sub
The only thing i can get to work is simple: hello world
Sub CommandButton2_Click()
msgbox "Hello World"
End Sub
Thanks
fordraiders
Have you added reference Microsoft ActiveX Data Object library?
ASKER
yes
What is the error you get?
ASKER
expected end of statement
line 21
Remember i'm in "Script Editor" of the Custom Form
and line 21 is this
Dim cnn As ADODB.Connection
line 21
Remember i'm in "Script Editor" of the Custom Form
and line 21 is this
Dim cnn As ADODB.Connection
ASKER
ok..
i did this:
Dim cnn
Set cnn = New ADODB.Connection
got past my previous error:
got the msgbox
but now getting :
class not defined ADODB
i did this:
Dim cnn
Set cnn = New ADODB.Connection
got past my previous error:
got the msgbox
but now getting :
class not defined ADODB
ASKER
ok.
got it to work with this:
Dim cnn
Set cnn = CreateObject("ADODB.Connec tion")
Now, how do i declare recordset?
got it to work with this:
Dim cnn
Set cnn = CreateObject("ADODB.Connec
Now, how do i declare recordset?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok i wil try it out..
It will take a few...
I will get back.,
Thanks
It will take a few...
I will get back.,
Thanks
ASKER
Dim cnn
Set cnn = CreateObject("ADODB.Connec tion")
Dim rs1
dim connectstring
Dim tp
' Open a Connection using an ODBC DSN named "SS PROGRAM WORKFLOW".
cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=dddddd025.com;UID=x xxxx;PWD=x xxxx;DATAB ASE=progra m_workflow "
sQuery = "Select * from temp_proposal_survey_resul ts;"
set rs1 = CreateObject("ADODB.Record set")
rs1.open sQuery, cnn, adOpenDynamic
tp = rs1.recordcount
if tp = "" then
msgbox "hello recordcount"
end if
' Close the connection.
cnn.Close
Not getting any errors but,,..not opening the recordset either ??
Set cnn = CreateObject("ADODB.Connec
Dim rs1
dim connectstring
Dim tp
' Open a Connection using an ODBC DSN named "SS PROGRAM WORKFLOW".
cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=dddddd025.com;UID=x
sQuery = "Select * from temp_proposal_survey_resul
set rs1 = CreateObject("ADODB.Record
rs1.open sQuery, cnn, adOpenDynamic
tp = rs1.recordcount
if tp = "" then
msgbox "hello recordcount"
end if
' Close the connection.
cnn.Close
Not getting any errors but,,..not opening the recordset either ??
ASKER
finally...got this to work.
Const adUseClient = 3
Dim cnn
Set cnn = CreateObject("ADODB.Connec tion")
Dim rs1
Dim connectstring
Dim tp
Dim q
' Open a Connection using an ODBC DSN named "SS PROGRAM WORKFLOW".
cnn.CursorLocation = adUseClient
cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=XXXXX.XXer.com;UID= XXXXXXuser ;PWD=XXXXX userprd;DA TABASE=wor kflow"
sQuery = "Select * from [survey_results]"
Set rs1 = CreateObject("ADODB.Record set")
rs1.open sQuery, cnn
rs1.MoveFirst
tp = rs1.recordcount
If tp = 1 Then
MsgBox "One Record"
End if
' Close the connection.
cnn.Close
Set cnn = nothing
Const adUseClient = 3
Dim cnn
Set cnn = CreateObject("ADODB.Connec
Dim rs1
Dim connectstring
Dim tp
Dim q
' Open a Connection using an ODBC DSN named "SS PROGRAM WORKFLOW".
cnn.CursorLocation = adUseClient
cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=XXXXX.XXer.com;UID=
sQuery = "Select * from [survey_results]"
Set rs1 = CreateObject("ADODB.Record
rs1.open sQuery, cnn
rs1.MoveFirst
tp = rs1.recordcount
If tp = 1 Then
MsgBox "One Record"
End if
' Close the connection.
cnn.Close
Set cnn = nothing
ASKER
thanks