 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 27th, 2006, 06:25 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Accessing a VBA module's method from VBScript
Greetings,
I am working on automating update tasks for some of my Access databases, and I have started playing around with Windows Scripting. I am still very new to VBScript, and I can't really say I have a great understanding of it.
That said, does anyone know if I can access any methods developed in VBA for an Access database from one of these VBScripts? I already have the import method written out in VBA, and it would be very nice if I could invoke from a script.
Thanks for the help.
|
|

November 28th, 2006, 08:35 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Anything you can do in VBA inside of Access, you can do outside of Access with a VBScript.
What do you want to do?
Do you want to import data to an Access database? If so, you would use some slightly different code than import.
You would need to open two connections, one to each data source.
Then open two recordsets, one for the source data, and one for the target location.
Then loop through the source data and tell it which fields to populate in the target table.
It looks pretty much the same as using this method from within Access (except you don't type the variables since VBScript is typeless.)
What help do you need?
mmcdonal
|
|

November 28th, 2006, 09:18 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the response,
Basically, the import process makes a connection to a flat text file and does a "select into" a temp table. After that, it works off the temp table to update all the data tables.
The import process has already been written in VBA to be invoked directly by the user. Now that I am looking into the VBScripts, I was wondering if there was any way I could invoke this method (it's a public method of a module) from the VBScript without having to rewrite it in VBScript. Also, I would like for the user to still be able to manually invoke the import process, so I would like to avoid having two versions of the same import process to maintain if possible.
I started looking into creating COM libraries, but have only really scratched the surface. Do you know if that would be the best approach?
|
|

November 28th, 2006, 09:27 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
I am not sure of the COM objects, but could look into that if that was what you wanted to do.
Basically to create the VBScript version, you could just copy and paste the code and change the connection references slightly, and remove the variable types.
Another option would be to create a version of an access database that you could launch, and a main form would open, and the main form's On Load event could run your code, then the form could stay on a timer for a few seconds and then the app could close.
mmcdonal
|
|
 |