Dan Waters
dwaters at usinternet.com
Fri Jan 25 10:15:57 CST 2008
Yes - that's exactly what I do. The Schedule actually calls a very small database which opens the main database which contains all the auto-email code. I prefer to keep the auto-email code in the main database - Schedule is not always 100% reliable, so if it didn't work then the first person who opens the database will trigger sending out the emails. (Send out emails records the current date - check to be sure you're past that date before sending emails.) In the small database (MorningReminders.mdb) I use this code: In MorningReminders.mdb there is a startup form with this single procedure: ----------------------------- Private Sub Form_Load() Call OpenFE End Sub ---------------------------------------------------- In a module called Startup is this single procedure: ---------------------------- Public Sub OpenFE() On Error GoTo EH Dim stgAccessPath As String Dim stgFEPath As String Dim stgWorkgroupPath As String Dim stgUserNamePassword As String Dim varAppOpen As Variant Dim stgShell As String Dim stgMorningRemindersPath As String Dim stg As String Dim rst As DAO.Recordset stgMorningRemindersPath = CurrentProject.Path stg = "SELECT * FROM tblParameters" Set rst = CurrentDb.OpenRecordset(stg, dbOpenSnapshot) '-- Create target string stgAccessPath = Chr(34) & SysCmd(acSysCmdAccessDir) & "MSAccess.exe" & Chr(34) stgFEPath = " " & Chr(34) & Replace(stgMorningRemindersPath, "MorningReminders", "FrontEnd") & "\" & rst("FEName") & Chr(34) stgWorkgroupPath = " /WRKGRP " & Chr(34) & Replace(stgMorningRemindersPath, "MorningReminders", "Workgroup") & "\" & rst("WorkgroupName") & Chr(34) stgUserNamePassword = " /USER " & Chr(34) & rst("UserName") & Chr(34) & " /PWD " & Chr(34) & rst("Password") & Chr(34) rst.Close Set rst = Nothing '-- Concatenate path stgShell = stgAccessPath _ & stgFEPath _ & stgWorkgroupPath _ & stgUserNamePassword '-- Open FE on Client varAppOpen = Shell(stgShell, vbMaximizedFocus) Application.Quit acQuitSaveNone Exit Sub EH: Application.Quit acQuitSaveNone End Sub -------------------------------------------------------- There is also a table in MorningReminders.mdb (tblParameters) that contains all the parameters. Now, the main database will know who is logging in by the built-in CurrentUser function. Because the main database maintains a log when people log in, you can pull a report of when the MorningReminders database actually triggered the auto-emails. HTH, Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at Beach Access Software Sent: Friday, January 25, 2008 9:33 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Retrieve command line arguments Dan: They'll be using (I assume) Windows scheduler to start it up, send the emails, and close. When the app opens I need to know if its for use by a user, or to run the emails and close. I figure a command line option is just the ticket. But I need to be able to retrieve the command line that started the app to those options, if they're there. Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters Sent: Friday, January 25, 2008 7:13 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Retrieve command line arguments Rocky, I use a startup form (hidden). In the Open event for that form, I have a long list of Calls to other procedures and functions, which do a myriad of things - including send out reminder emails if this is the first time the db has been opened for the day. This has been a straightforward and reliable method so far! HTH! Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at Beach Access Software Sent: Friday, January 25, 2008 8:53 AM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Retrieve command line arguments Dear List: I want to run a function in an application (emails out reports) automatically. I see that one way to do this is to use the /x switch on startup to run a macro which will run a module which could have Application.Quit at the end of it. But I can't seem to get this to work. And besides, I'm under the impression that macros are not PC anymore. Anyway, if I can 'see' the startup switches on the command line that calls access and starts the app, I suppose I could intercept al the startup housekeeping, run the reports, send the emails and exit. Is there a way to see what the command was that started an app , IOW retrieve the command line arguments ? Or is there a better way to do this? The automated email sender has to be part of the larger app - originally it was split off for development purposes, but now, it's part of the design that it should be integrated into the application. MTIA Rocky -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.11/1242 - Release Date: 1/24/2008 8:32 PM -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com