[RESOLVED] Works manually, not in auto mode
I have an app that I'm trying to fire off automatically every morning. I've created the app and I can run the executable and it works if I manually run the program... there are no errors and it appears to do its job.
However, when I set it up to run automatically (using AT from the command line and passing the app a parameter to tell it to shut itself down after running, I get errors (Error 6 - Overflow). My program continues on, but I get about 3 of these in my error log file.
The program is simple... it talks to 2 databases on 5 sucsessive calls and emails out some reports if any are overdue.
I don't know how to trap the error because it doesn't do it when I run it through the IDE or even manually running the EXE.
If anyone has any idea why this might be happening, I'd love to hear it.
Re: Works manually, not in auto mode
I don't know how you are exiting your program, but you probably aren't closing all objects that you opened. You have to unload them and set them to nothing. You also have to close all forms.
Here is a routine that I call on a button click to shut down everything.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim frm As Form
Dim obj As Object
For Each frm In Forms
If frm.Name <> Me.Name Then ' Unload this form LAST
For Each obj In frm
On Error Resume Next
Unload obj
Set obj = Nothing
Next
Unload frm
Set frm = Nothing
End If
Next
On Error Resume Next
For Each obj In frm
Unload obj
Set obj = Nothing
Next
Set frm = Nothing
Unload Me
End Sub
Re: Works manually, not in auto mode
It's not really a question of exiting the program. It exits the program fine. It's a question of why it doesn't process the data without errors when run automatically when it works fine when in manual.
Re: Works manually, not in auto mode
When you run it manually, do you run it from the command line with the same passed parameter?
Re: Works manually, not in auto mode
Well, I've run it both from the IDE and by just double-clicking the EXE.
However, after doing a bunch of testing, I've narrowed it down to the fact that it never connects to the database. This just doesn't make sense. It connects fine when running it manually.
Re: Works manually, not in auto mode
Since we are all gropping around in the dark, could it have anything to do with the time of day?
Re: Works manually, not in auto mode
Did You Try Running From The Command Line With Same Parameters You Pass When You Run Using The AT Command
Re: Works manually, not in auto mode
Or maybe a user/password problem?
Maybe you could use a batch file with the START command?
Re: Works manually, not in auto mode
It's not the time of day, because as I'm testing, I keep setting it up using the AT command and passing the parameter. So I've ran it about 30 times in the past 2 hours. I've also run it from the IDE passing the parameter through the properties of the project.
No matter what I do, running from the IDE or the executable without the auto parameter works. Running from the IDE with the auto parameter works. Yet, running from the executable through the AT command with the parameter fails.
I'm running out of places to look real damn fast.
Re: Works manually, not in auto mode
AAAnnnd... I think I'm an idiot. This is also weird, however... if I open the app, it gets the server names out of the registry. So I open it manually and change them to what they need to be and close the app (saving those settings). However, when it runs through the AT command, it doesn't grab those values. It takes the default, which was the server I used to be on (never updated the code). So obviously it isn't going to connect. Now I'm wondering why it doesn't grab the same values.
Re: Works manually, not in auto mode
*sigh*.... sorry for the rat race all. I've moved the settings into an INI file and everything is working now.