By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,905 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,905 IT Pros & Developers. It's quick & easy.

Simple command line prompt to call MS Access Module?

P: n/a
Hi All:

I was wondering if there's a simple way to call a MS Access Module
through either
Command Prompt
MS Script
any other way...

Thanks for the response.

I am trying to extract some data out of a table in Access on a
scheduled basis, I figured the simplest way is to do a simple module,
have some command to extract the information, then schedule it.

thx again
tony

Mar 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Yes, sort of.

You can call a macro in the command line when you open Access. The macro
could have the RunCode command which will run a VBA function.

Example:
"<path>\msaccess.exe" "<path>\MyDatabase.mdb" /x MacroName

You can also use an AutoExec macro to automatically run code when you open
the database or place code in the Open event of your startup form to run the
procedures you need.

Another option is to use the /cmd switch on the command line. You can then
use the Command() function in code to extract this information to react as
desired.

--
Wayne Morgan
MS Access MVP
<to********@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hi All:

I was wondering if there's a simple way to call a MS Access Module
through either
Command Prompt
MS Script
any other way...

Thanks for the response.

I am trying to extract some data out of a table in Access on a
scheduled basis, I figured the simplest way is to do a simple module,
have some command to extract the information, then schedule it.

thx again
tony

Mar 23 '06 #2

P: n/a
<to********@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hi All:

I was wondering if there's a simple way to call a MS Access Module
through either
Command Prompt
MS Script
any other way...

Thanks for the response.

I am trying to extract some data out of a table in Access on a
scheduled basis, I figured the simplest way is to do a simple module,
have some command to extract the information, then schedule it.

thx again
tony

If the machine which is going to run the scheduled task has Access on it,
then you could call something like this:

"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE"
"C:\MyExtractor.mdb" /cmd "DoExtract"

The database MyExtractor.mdb has all of the functions in a module together
with an AutoExec macro. The macro has a single step of RunCode where the
function is =DoExtract()

Public Function DoExtract()

Dim strCommand As String

strCommand = Command()

If StrComp(strCommand, "DoExtract", vbBinaryCompare) = 0 Then
' Code to do the extract
Else
' Wrong start code - so quit
Application.Quit
End If

End Function
The code could do whatever extraction was needed and then shut itself down.
The disadvantage of this is you need Access installed (and scheduled tasks
are often run from a server where this is not the case) and also the fact
that Access is a big program to start if all you need to do is extract a bit
of data.
You could create a vbs file which does it all without needing Access at all.
This has the advantage that you only need notepad to write it, but VBScript
suffers from being weakly-typed and offers quite limited error handling.
However, if you wrote it carefully, you would be OK. If you wanted the
advantage of a small program loading together with error handling you would
need something like Visual Basic to create an exe file.


Mar 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.