Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run an event procedure from the command line?

Status
Not open for further replies.

f100engineer

Technical User
Nov 21, 2002
6
US
I have been trying to figure out a way to run a Private Sub through the command line.

For instance, I have a command button that is linked to an event procedure. I would like to run that procedure from the command line, like:

c:\databases\mydatabase.mdb /[command to run private sub]

This would be very beneficial as I could do work from home.
 
Can you explain a little more of what you are trying to do. Do you want to start up Access from the command line and then pass a parm to execute certain procedures and then exit.
 
Yes,
Instead of opening up the data base, clicking on the command buttons to do the job, I would like to make an ICON on my desktop that has this run command attached to it...one click, and job is done.
 
I set up an application like that, but there are a lot of pieces. I could send you the directory with all the processing along with the app. Let me know and provide an email address.
 
F100Engineer, try this - you can put a MACRO name on the command line. Write a macro that does a RUNCODE of your funtion. Should be a snap. Open the db with the macro name as a command line argument, and you're off an RUNning.. LOL ;)

Jim Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
The problem with this is the part I want to run is a Private Sub. I have been reading and haven't found the proper way to assign a macro to run a private sub. Here is my code which I want to run from an icon:

Private Sub Output_Composite_Sto_Click()
On Error GoTo Output_Composit_Sto_Click_Error
Dim strline
Dim myOlApp, myNameSpace, myMailItem
Dim msgRTFBody As String

DoCmd.OutputTo acOutputReport, "Composite Morning Story", acFormatRTF, "\\cpu1025\grpdirs\EngTest\F100 INFO\Morning Story\morningstory.doc", True

Review_Morning_Stories:
Dim RetValue
RetValue = MsgBox("Ok To Send Morning Story?", vbOKCancel, "Attention")
If RetValue = vbOK Then
GoTo Email_Morning_Story
ElseIf RetValue = vbCancel Then
GoTo Output_Composit_Sto_Click_Exit
End If

Email_Morning_Story:
Open "\\cpu1025\grpdirs\EngTest\F100 INFO\Morning Story\morningstory.doc" For Input As #1
Do Until EOF(1)
Line Input #1, strline
msgRTFBody = msgRTFBody & strline
Loop
Close #1

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myMailItem = myOlApp.CreateItem(olMailItem)
With myMailItem
.To = "user@isp.com"
.Subject = "F100 Composite Morning Story " & DATE
.Body = msgRTFBody
.Send
End With

Set myMailItem = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing

Output_Composit_Sto_Click_Exit:
Exit Sub

Output_Composit_Sto_Click_Error:
Select Case Err.Number
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description, , "Composite Morning Story"
Resume Output_Composit_Sto_Click_Exit
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top