Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Querying Data from Access

All,
I am using the charting features in Excel 2007 to build various charts from
data stored in Access. I want the user to be able to select the Region,
Country, or Site that he wishes to see data for, along with a range of dates.

I have queries in Access that will summarize the data the way I need it.
What I would like to know, is how do I "paramaterize" the queries so that I
can use the dates the user chooses, for example?

Thanks,
Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Querying Data from Access

Here is a good example from EXCEL VBA 2003. for I think what you're wanting

Public Sub CallStoredProcedure()

Const ConnectionString As String = _
"Provider=SQLOLEDB.1;Integrated Security=SSPI;" + _
"Persist Security Info=False;Initial Catalog=NorthwindCS;" + _
"Data Source=LAP800;Workstation ID=LAP800;"

Dim Command As Command
Set Command = New Command

Command.ActiveConnection = ConnectionString
Command.CommandText = "[Sales by Year]"
Command.CommandType = CommandTypeEnum.adCmdStoredProc

Dim BeginningDate As ADODB.Parameter
Dim EndingDate As ADODB.Parameter

Dim StartDate As Date
StartDate = #1/1/1995#

Dim EndDate As Date
EndDate = #1/1/2004#

Set BeginningDate = Command.CreateParameter("@Beginning_Date", _
DataTypeEnum.adDate, ParameterDirectionEnum.adParamInput, , StartDate)

Set EndingDate = Command.CreateParameter("@Ending_Date", _
DataTypeEnum.adDate, ParameterDirectionEnum.adParamInput, , EndDate)

Call Command.Parameters.Append(BeginningDate)
Call Command.Parameters.Append(EndingDate)

Dim Recordset As ADODB.Recordset
Set Recordset = Command.Execute

Call Sheet1.Range("A1").CopyFromRecordset(Recordset)

End Sub


"Steve Haack" wrote:

All,
I am using the charting features in Excel 2007 to build various charts from
data stored in Access. I want the user to be able to select the Region,
Country, or Site that he wishes to see data for, along with a range of dates.

I have queries in Access that will summarize the data the way I need it.
What I would like to know, is how do I "paramaterize" the queries so that I
can use the dates the user chooses, for example?

Thanks,
Steve

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
Error in querying data from MS Access aemAndy Excel Discussion (Misc queries) 1 April 16th 07 06:54 PM
QUERYING ACCESS Drew Excel Discussion (Misc queries) 3 July 13th 05 07:25 AM
Querying data from Access Steve J Excel Worksheet Functions 0 June 14th 05 10:16 AM
Querying Data from Access Stefan Excel Discussion (Misc queries) 2 June 2nd 05 07:10 PM
Querying Data from Secured Access Database with VBA VBA Dabbler[_2_] Excel Programming 9 February 18th 05 09:15 PM


All times are GMT +1. The time now is 02:20 AM.

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

About Us

"It's about Microsoft Excel"