Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default Compile Error\Interacting with Access

I got this VBA from a John Walkenbeth website Demo file. This VBA is just
what I need to resolve a problem at. However , I get a Compile Error:
User-defined type not defined. Below is the code and underlined is where the
error occurs:

Sub ADO_Demo()
' This demo requires a reference to
' the Microsoft ActiveX Data Objects 2.x Library

Dim DBFullName As String
Dim Cnct As String, Src As String
Dim Connection As ADODB.Connection <===== Compile Error
Dim Recordset As ADODB.Recordset
Dim Col As Integer

Cells.Clear
MsgBox "This retrieves the updated data for the records in which UNIT =
125 LOGISTICS READINESS SQ and PASCODE = C21CF2BF"

' Database information
DBFullName = ThisWorkbook.Path & "\budget.mdb"

' Open the connection
Set Connection = New ADODB.Connection
Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
Cnct = Cnct & "Data Source=" & DBFullName & ";"
Connection.Open ConnectionString:=Cnct

' Create RecordSet
Set Recordset = New ADODB.Recordset
With Recordset
' Filter
Src = "SELECT * FROM Budget WHERE Unit = '125 LOGISTICS READINES SQ' "
Src = Src & "and PASCODE = 'C21CF2BF'"
.Open Source:=Src, ActiveConnection:=Connection

' Write the field names
For Col = 0 To Recordset.Fields.Count - 1
Range("B8").Offset(0, Col).Value = Recordset.Fields(Col).Name
Next

' Write the recordset
Range("B8").Offset(1, 0).CopyFromRecordset Recordset
End With
Set Recordset = Nothing
Connection.Close
Set Connection = Nothing
End Sub

Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Compile Error\Interacting with Access

Alt-F11 and don't forget to add the references.

Tools|References and check the box for 'Microsoft ActiveX Data Objects 2.x
Library'


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Curt" wrote:
|I got this VBA from a John Walkenbeth website Demo file. This VBA is just
| what I need to resolve a problem at. However , I get a Compile Error:
| User-defined type not defined. Below is the code and underlined is where
the
| error occurs:
|
| Sub ADO_Demo()
| ' This demo requires a reference to
| ' the Microsoft ActiveX Data Objects 2.x Library
|
| Dim DBFullName As String
| Dim Cnct As String, Src As String
| Dim Connection As ADODB.Connection <===== Compile Error
| Dim Recordset As ADODB.Recordset
| Dim Col As Integer
|
| Cells.Clear
| MsgBox "This retrieves the updated data for the records in which UNIT =
| 125 LOGISTICS READINESS SQ and PASCODE = C21CF2BF"
|
| ' Database information
| DBFullName = ThisWorkbook.Path & "\budget.mdb"
|
| ' Open the connection
| Set Connection = New ADODB.Connection
| Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
| Cnct = Cnct & "Data Source=" & DBFullName & ";"
| Connection.Open ConnectionString:=Cnct
|
| ' Create RecordSet
| Set Recordset = New ADODB.Recordset
| With Recordset
| ' Filter
| Src = "SELECT * FROM Budget WHERE Unit = '125 LOGISTICS READINES
SQ' "
| Src = Src & "and PASCODE = 'C21CF2BF'"
| .Open Source:=Src, ActiveConnection:=Connection
|
| ' Write the field names
| For Col = 0 To Recordset.Fields.Count - 1
| Range("B8").Offset(0, Col).Value = Recordset.Fields(Col).Name
| Next
|
| ' Write the recordset
| Range("B8").Offset(1, 0).CopyFromRecordset Recordset
| End With
| Set Recordset = Nothing
| Connection.Close
| Set Connection = Nothing
| End Sub
|
| Any help would be appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default Compile Error\Interacting with Access

Thanks, Dave.

I'm relatively new to the VBA areana.

However, now I get a run-time error'-2147217904(80040e10)': No value given
for one or more required parameters. I select the debug option and it
highlights this VBA code:

..Open Source:=Src, ActiveConnection:=Connection

"Dave Patrick" wrote:

Alt-F11 and don't forget to add the references.

Tools|References and check the box for 'Microsoft ActiveX Data Objects 2.x
Library'


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Curt" wrote:
|I got this VBA from a John Walkenbeth website Demo file. This VBA is just
| what I need to resolve a problem at. However , I get a Compile Error:
| User-defined type not defined. Below is the code and underlined is where
the
| error occurs:
|
| Sub ADO_Demo()
| ' This demo requires a reference to
| ' the Microsoft ActiveX Data Objects 2.x Library
|
| Dim DBFullName As String
| Dim Cnct As String, Src As String
| Dim Connection As ADODB.Connection <===== Compile Error
| Dim Recordset As ADODB.Recordset
| Dim Col As Integer
|
| Cells.Clear
| MsgBox "This retrieves the updated data for the records in which UNIT =
| 125 LOGISTICS READINESS SQ and PASCODE = C21CF2BF"
|
| ' Database information
| DBFullName = ThisWorkbook.Path & "\budget.mdb"
|
| ' Open the connection
| Set Connection = New ADODB.Connection
| Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
| Cnct = Cnct & "Data Source=" & DBFullName & ";"
| Connection.Open ConnectionString:=Cnct
|
| ' Create RecordSet
| Set Recordset = New ADODB.Recordset
| With Recordset
| ' Filter
| Src = "SELECT * FROM Budget WHERE Unit = '125 LOGISTICS READINES
SQ' "
| Src = Src & "and PASCODE = 'C21CF2BF'"
| .Open Source:=Src, ActiveConnection:=Connection
|
| ' Write the field names
| For Col = 0 To Recordset.Fields.Count - 1
| Range("B8").Offset(0, Col).Value = Recordset.Fields(Col).Name
| Next
|
| ' Write the recordset
| Range("B8").Offset(1, 0).CopyFromRecordset Recordset
| End With
| Set Recordset = Nothing
| Connection.Close
| Set Connection = Nothing
| End Sub
|
| Any help would be appreciated.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Compile Error\Interacting with Access

Please paste a link to John's demo so I can see what you're seeing.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Curt" wrote:
| Thanks, Dave.
|
| I'm relatively new to the VBA areana.
|
| However, now I get a run-time error'-2147217904(80040e10)': No value given
| for one or more required parameters. I select the debug option and it
| highlights this VBA code:
|
| .Open Source:=Src, ActiveConnection:=Connection


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Compile Error\Interacting with Access

http://www.dummies.com/WileyCDA/Dumm...24,page-1.html

It's in the Chp. 23 download the ADO_Demo file and Budget.mbd

"Dave Patrick" wrote:

Please paste a link to John's demo so I can see what you're seeing.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Curt" wrote:
| Thanks, Dave.
|
| I'm relatively new to the VBA areana.
|
| However, now I get a run-time error'-2147217904(80040e10)': No value given
| for one or more required parameters. I select the debug option and it
| highlights this VBA code:
|
| .Open Source:=Src, ActiveConnection:=Connection





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Compile Error\Interacting with Access

If you open the Access database and look at the table Budget you'll find
there are no columns [Unit] or [PASCODE] which is why it fails with that
error. For the purpose of completing your task replace;

Src = "SELECT * FROM Budget WHERE Unit = '125 LOGISTICS READINES SQ' and
PASCODE = 'C21CF2BF' "
Src = Src & "and PASCODE = 'C21CF2BF'"

'with this to make it work;
Src = "SELECT * " _
& "FROM Budget " _
& "WHERE (((DEPARTMENT)='Human Resources') AND ((BUDGET)=2859)); "


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"CurtH" wrote:
|
http://www.dummies.com/WileyCDA/Dumm...24,page-1.html
|
| It's in the Chp. 23 download the ADO_Demo file and Budget.mbd


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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
interacting with MS Access gottahavit Excel Programming 1 July 15th 05 05:53 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 06:15 PM.

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"