Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running an Access function (with parameters) from Excel

I am using Excel as the customer interface and they will need to change the connection string in the back end access database. I have built the function in Access - called Sub ChangeXLlinkConnection(ByVal FilePath As String, ByVal SheetName As String, strExcelTableName As String). Within Access, I can successfully change the links.

So... I am trying to provide the variables from excel and execute the link change from Excel. (FilePath, SheetName, and strExcelTableName are maintained in excel).

I have seen code such as...

Public Sub main2()
Dim strDBName As String
Dim FilePath As String
Dim SheetName As String
Dim strExcelTableName As String


strDBName = "C:\Test\Staging.accdb" 'Database that houses the linked file
FilePath = "C:\Test\Style Color.xls" 'Excel Workbook used to link
SheetName = "sheet1" 'Tab in Excel being linked
strExcelTableName = "tblMyData" 'Linked Access Table being changed

With CreateObject("Access.Application")
.OpenCurrentDatabase strDBName
.Run "ChangeXLlinkConnection" 'function within Access to be run
.Quit
End With
MsgBox "Done"
End Sub

With that said, the ".run..." line will fail. granted, I do not have the parameters shown but I when the were added, I had the same result.

Any help would be appreciated.

Thank you in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Running an Access function (with parameters) from Excel

Update:

I was successful in the following code but now need to pass the parameters and have NOT been successful. The new function "RunIT" (See below) was created to pass the parameters from within Access.

Sub main3()
Dim strDBName As String
Dim strMessage As String
Dim FilePath As String
Dim SheetName As String
Dim strExcelTableName As String

strDBName = ThisWorkbook.Path & "\" & "Staging.accdb"
FilePath = ThisWorkbook.Path & "\" & "Style Color.xls"
SheetName = "MA DATA"
strExcelTableName = "tblStyleColor"

With CreateObject("Access.Application")
.OpenCurrentDatabase strDBName
.Run "RunIT"
.Quit
End With

MsgBox "Done"
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Running an Access function (with parameters) from Excel

Have you tried just running the processes entirely within Excel? You
don't need links because ADODB will work for this nicely, even to run
stored procedures in your Access db!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Running an Access function (with parameters) from Excel

Thanks Garry, I like were you are going there. Can you or anyone, provide some link(s) to direct me to the process of making that happen? I have never done this and would appreciate some direction.

Thanks again.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Running an Access function (with parameters) from Excel

Thanks Garry, I like were you are going there. Can you or anyone, provide
some link(s) to direct me to the process of making that happen? I have never
done this and would appreciate some direction.

Thanks again.


Here's a good place to start...

http://www.appspro.com/conference/Da...rogramming.zip

--
Garry

Free uenet access at http://www.eternal-september.org
Classic VB Users Regroup
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Running an Access function (with parameters) from Excel

Nice job! Thanks for the feedback...

--
Garry

Free uenet access at http://www.eternal-september.org
Classic VB Users Regroup
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Access doesn't always close (Excel VBA) & passing parameters Lee Harper-Smith Excel Programming 0 August 4th 09 05:06 PM
Query from Excel to Access - Passing Parameters? Marc T Excel Programming 8 February 4th 09 01:54 PM
Run an Access Query from Excel VBA with Parameters SupperDuck Excel Programming 1 March 2nd 07 03:39 PM
Running a Excel function from access vba [email protected] Excel Programming 1 May 9th 06 04:33 PM
Passing parameters from excel to access Jabeen Excel Programming 2 April 5th 05 12:33 PM


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

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"