mkramer777
asked on
Access
I have an access database that loads a text file into the database. I have to hit a button on the database form to do this. Is there a way to automate this? I want it to run nightly at a certain time. Maybe I need some other software to do this.
In the Windows Task Scheduler you need to specify as the Run command
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.E XE" "c:\Temp\AccessDBName.mdb" /x "MacroName"
Let me know if you need help setting this up.
OM Gang
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.E
Let me know if you need help setting this up.
OM Gang
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What if this is a win xp pro machine running access 2000? Also, can you send any documentation on writing the macro or is that pretty simple?
Works for Win XP Pro.
To create the Macro is pretty straight forward.
Please post the code for your current button_click routine. We'll start there, modify it to make a stand-alone function and then create a Macro to call that function.
OM Gang
To create the Macro is pretty straight forward.
Please post the code for your current button_click routine. We'll start there, modify it to make a stand-alone function and then create a Macro to call that function.
OM Gang
ASKER
I'm a bit of a novice on this. Where do I find and copy the code from access?
On your form, in Design view, select the button. In the Properties dialogue, for the OnClick event you should see [Event Procedure]. Double-click that to open the VBE (Visual Basic Editor) and display the buttons OnClick procedure. Copy the entire procedure and paste it here.
OM Gang
OM Gang
Actually the way I do it is I have form that opens with the database opening. The On Load event is as shown below. You don't even see the form blink by if you open it outside the time in the code. Then the scheduled task is just a simple open the DB command. And if you want to open the DB to do edits it opens normally and brings up the DB window.
And if it is a user interface database, you could open the user form. Or put it in that form's on load event.
And if it is a user interface database, you could open the user form. Or put it in that form's on load event.
Private Sub Form_Load()
DoCmd.RunCommand acCmdSizeToFitForm
'Me.Run_Import.SetFocus
If TimeValue(Now()) > #7:00:00 AM# And TimeValue(Now()) < #8:00:00 AM# Then
RunImports
DoCmd.Quit acQuitSaveAll
End If
DoneAndQuit
End Sub
Private Function DoneAndQuit()
DoCmd.Close acForm, "AutoRun", acSaveYes
End Function
I like it.
OM Gang
OM Gang
OM Gang