#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't I click the Subtotal button? mlanger Excel Worksheet Functions 3 March 12th 07 08:27 AM
further options following a command button click thesaxonuk Excel Discussion (Misc queries) 0 October 23rd 06 01:46 PM
Name of Text-Box Right-Click Command Bar? Altamont Excel Discussion (Misc queries) 1 September 26th 06 09:07 PM
Is there any way to have a maco click a command button ChairMan Excel Discussion (Misc queries) 0 March 23rd 06 03:58 PM
Linking one worksheet to another by click on a command button Ken Vo Excel Discussion (Misc queries) 0 January 6th 06 12:41 AM


All times are GMT +1. The time now is 07:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"