ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Command Button Click (https://www.excelbanter.com/excel-discussion-misc-queries/165295-command-button-click.html)

bmolintas

Command Button Click
 
I want to assign the following code to a button on my Excel 2003 spreadsheet.
When I click the button, I receive a Microsoft Visual Basic Error "Compile
Error: User-defined type not defined"

Dim Con As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Cmd2 As New ADODB.Command
Dim Rs As ADODB.Recordset

Con.Open "DSN=KIAMOTOR;"
Set Cmd.ActiveConnection = Con
Cmd.CommandText = "SELECT * FROM PTFGRPP"

Thanks in advance for the help.

Jim Thomlinson

Command Button Click
 
Did you make a reference to "Microsoft ActiveX Data Objects ?.? Library"
Tools - References in the VBE
You need that if you want to use ADODB
--
HTH...

Jim Thomlinson


"bmolintas" wrote:

I want to assign the following code to a button on my Excel 2003 spreadsheet.
When I click the button, I receive a Microsoft Visual Basic Error "Compile
Error: User-defined type not defined"

Dim Con As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Cmd2 As New ADODB.Command
Dim Rs As ADODB.Recordset

Con.Open "DSN=KIAMOTOR;"
Set Cmd.ActiveConnection = Con
Cmd.CommandText = "SELECT * FROM PTFGRPP"

Thanks in advance for the help.


bmolintas

Command Button Click
 
I added the reference and am no longer receiving the error but clicking the
button does not pull down any recrods to the spreadsheet.

"Jim Thomlinson" wrote:

Did you make a reference to "Microsoft ActiveX Data Objects ?.? Library"
Tools - References in the VBE
You need that if you want to use ADODB
--
HTH...

Jim Thomlinson


Jim Thomlinson

Command Button Click
 
Please post all of your code... When you look at your recordset (rs) is there
anything in it?
--
HTH...

Jim Thomlinson


"bmolintas" wrote:

I added the reference and am no longer receiving the error but clicking the
button does not pull down any recrods to the spreadsheet.

"Jim Thomlinson" wrote:

Did you make a reference to "Microsoft ActiveX Data Objects ?.? Library"
Tools - References in the VBE
You need that if you want to use ADODB
--
HTH...

Jim Thomlinson


bmolintas

Command Button Click
 
This is the code I have behind my command button.

Private Sub CommandButton2_Click()
Dim Con As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Cmd2 As New ADODB.Command
Dim Rs As ADODB.Recordset

Con.Open "DSN=KIAMOTOR;"
Set Cmd.ActiveConnection = Con
Cmd.CommandText = "SELECT * FROM PTFGRPP"
End Sub

"Jim Thomlinson" wrote:

Please post all of your code... When you look at your recordset (rs) is there
anything in it?
--
HTH...

Jim Thomlinson


"bmolintas" wrote:

I added the reference and am no longer receiving the error but clicking the
button does not pull down any recrods to the spreadsheet.

"Jim Thomlinson" wrote:

Did you make a reference to "Microsoft ActiveX Data Objects ?.? Library"
Tools - References in the VBE
You need that if you want to use ADODB
--
HTH...

Jim Thomlinson



All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com