VB Code only runs when logged in

bharlow

Registered User.
Local time
Today, 15:52
Joined
Dec 26, 2008
Messages
52
I have a number of Access 2007 DB's on different clients servers that I send emails from daily. I send emails using two different methodologies.

First, summary emails go out via the SendObject Macro (no code). These go out every day with no problem.

Secondly, I send report bursting emails out via some simple code. This works for all but one of my clients daily.

The one client, however, I have to log on via remote connection. Once I do this, the emails which appear to be held in limbo, are relased.

Has anyone run into this problem where code will not run until logged in??
 
I have a number of Access 2007 DB's on different clients servers that I send emails from daily. I send emails using two different methodologies.

First, summary emails go out via the SendObject Macro (no code). These go out every day with no problem.

Secondly, I send report bursting emails out via some simple code. This works for all but one of my clients daily.

The one client, however, I have to log on via remote connection. Once I do this, the emails which appear to be held in limbo, are relased.

Has anyone run into this problem where code will not run until logged in??

What is the code you are using with the second method that is having an issue?
 
Here is the code. It works great on all our other servers and it works fine on this server as long as I am logged in.???Any help is greatly appreciated.


Private Sub cmdEmailIndividualCustReports_Click()
On Error GoTo Err_cmdEmailIndividualCustReports_Click

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strStore As String
Dim strRcpt As String

strSQL = "SELECT Store,Recipient From DISTTABLE2"
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset(strSQL)

'rst.MoveLast
rst.MoveFirst
'MsgBox rst.RecordCount

DoCmd.Echo False
Do While Not rst.EOF
strStore = rst!Store
strRcpt = rst!Recipient
'If Store is a number change to: "Store=" & strStore
DoCmd.OpenReport "CUS-RPT_WARBD2", acViewPreview, , "STR=" & strStore
DoCmd.SendObject acSendReport, "CUS-RPT_WARBD2", acFormatPDF, strRcpt, , , "Store Warboard", , False
DoCmd.Close acReport, "CUS-RPT_WARBD2"
rst.MoveNext
Loop
DoCmd.Echo True

rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing

Exit_cmdEmailIndividualCustReports_Click:

On Error Resume Next
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Exit Sub

Err_cmdEmailIndividualCustReports_Click:
MsgBox "There was an error executing the command." _
& vbCrLf & vbCrLf & "Error " & Err.Number & ": " _
& vbCrLf & vbCrLf & Error, vbExclamation
Resume Exit_cmdEmailIndividualCustReports_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom