Strange bug

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, need help with the following bug, I've split my DB into a front-end and a
back-end, the front-end is in each user's PC and the back end is in a server.
Now I have a bug that didn't happened before I splited the DB.
The bug is that when the user fires a button that runs a VB code to produce
several reports, at the end of the code Access opens Visual Basic Window
showing the code that it just executed, no error messages, nothing...
Has anyone ever heard about this????
Please help how do I stop VB window from showing up???
Thanks
 
How about posting all of the code in the button and any sub's or functions
called.
 
This is the code:

Public Function Comando001_Click()

DoCmd.SetWarnings WarningsOff
DoCmd.OpenQuery "append_numerario"

DoCmd.OpenReport "rpt_informacoes_diarias_consolidada", acViewPreview, , ,
acHidden
DoCmd.OutputTo acOutputReport, "rpt_informacoes_diarias_consolidada",
"SnapshotFormat(*.snp)",
"\\CASA-103E368BC4\SharedDocs\rpt_info_diarias_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"
DoCmd.Close acReport, "rpt_informacoes_diarias_consolidada", acSaveNo

DoCmd.OpenReport "rpt_Orcamentos_Consolidado", acViewPreview, , , acHidden
DoCmd.OutputTo acOutputReport, "rpt_Orcamentos_Consolidado",
"SnapshotFormat(*.snp)",
"\\CASA-103E368BC4\SharedDocs\rpt_Orcamentos_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"
DoCmd.Close acReport, "rpt_Orcamentos_Consolidado", acSaveNo

DoCmd.OpenReport "rpt_informacoes_servicos_diarios", acViewPreview, , ,
acHidden
DoCmd.OutputTo acOutputReport, "rpt_informacoes_servicos_diarios",
"SnapshotFormat(*.snp)",
"\\CASA-103E368BC4\SharedDocs\rpt_servicos_diarios_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"
DoCmd.Close acReport, "rpt_informacoes_servicos_diarios", acSaveNo

'DoCmd.OpenReport "rpt_Vendas_por_produto", acViewPreview, , , acHidden
'DoCmd.OutputTo acOutputReport, "rpt_Vendas_por_produto",
"SnapshotFormat(*.snp)",
"\\CASA-103E368BC4\SharedDocs\rpt_vendas_por_produto_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"
'DoCmd.Close acReport, "rpt_Vendas_por_produto", acSaveNo

DoCmd.OpenReport "rpt_Caixa_Vista_Directa", acViewPreview, , , acHidden
DoCmd.OutputTo acOutputReport, "rpt_Caixa_Vista_Directa",
"SnapshotFormat(*.snp)",
"\\CASA-103E368BC4\SharedDocs\rpt_Caixa_Vista_Directa_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"
DoCmd.Close acReport, "rpt_Caixa_Vista_Directa", acSaveNo

DoCmd.OpenReport "rpt_Despesas", acViewPreview, , , acHidden
DoCmd.OutputTo acOutputReport, "rpt_Despesas", "SnapshotFormat(*.snp)",
"\\CASA-103E368BC4\SharedDocs\rpt_Despesas_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"
DoCmd.Close acReport, "rpt_Despesas", acSaveNo

' Save the Snapshot file as a PDF document.
Dim blRet As Boolean
Dim sPDF As String
Dim sName As String
sName = "\\CASA-103E368BC4\SharedDocs\rpt_info_diarias_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"

If Len(sName & vbNullString) = 0 Then Exit Function
' let's use the name of the selected Snapshot file
' to name our converted PDF document.
sPDF = Mid(sName, 1, Len(sName) - 3)

blRet = ConvertReportToPDF(vbNullString, sName, sPDF & "PDF", False)

sName = "\\CASA-103E368BC4\SharedDocs\rpt_Orcamentos_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"

If Len(sName & vbNullString) = 0 Then Exit Function
' let's use the name of the selected Snapshot file
' to name our converted PDF document.
sPDF = Mid(sName, 1, Len(sName) - 3)

blRet = ConvertReportToPDF(vbNullString, sName, sPDF & "PDF", False)

sName = "\\CASA-103E368BC4\SharedDocs\rpt_servicos_diarios_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"

If Len(sName & vbNullString) = 0 Then Exit Function
' let's use the name of the selected Snapshot file
' to name our converted PDF document.
sPDF = Mid(sName, 1, Len(sName) - 3)

blRet = ConvertReportToPDF(vbNullString, sName, sPDF & "PDF", False)

'sName = "\\CASA-103E368BC4\SharedDocs\rpt_vendas_por_produto_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"

'If Len(sName & vbNullString) = 0 Then Exit Function
' let's use the name of the selected Snapshot file
' to name our converted PDF document.
'sPDF = Mid(sName, 1, Len(sName) - 3)

'blRet = ConvertReportToPDF(vbNullString, sName, sPDF & "PDF", False)

sName = "\\CASA-103E368BC4\SharedDocs\rpt_Caixa_Vista_Directa_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"

If Len(sName & vbNullString) = 0 Then Exit Function
' let's use the name of the selected Snapshot file
' to name our converted PDF document.
sPDF = Mid(sName, 1, Len(sName) - 3)

blRet = ConvertReportToPDF(vbNullString, sName, sPDF & "PDF", False)

sName = "\\CASA-103E368BC4\SharedDocs\rpt_Despesas_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"

If Len(sName & vbNullString) = 0 Then Exit Function
' let's use the name of the selected Snapshot file
' to name our converted PDF document.
sPDF = Mid(sName, 1, Len(sName) - 3)

blRet = ConvertReportToPDF(vbNullString, sName, sPDF & "PDF", False)

Kill "\\CASA-103E368BC4\SharedDocs\rpt_info_diarias_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"
Kill "\\CASA-103E368BC4\SharedDocs\rpt_Orcamentos_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"
Kill "\\CASA-103E368BC4\SharedDocs\rpt_servicos_diarios_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"
'Kill "\\CASA-103E368BC4\SharedDocs\rpt_vendas_por_produto_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"
Kill "\\CASA-103E368BC4\SharedDocs\rpt_Caixa_Vista_Directa_Amoreiras" &
Format(Date, "dd-mm-yyyy") & ".snp"
Kill "\\CASA-103E368BC4\SharedDocs\rpt_Despesas_Amoreiras" & Format(Date,
"dd-mm-yyyy") & ".snp"

MsgBox "Reports Gerados com Sucesso.", 48, "Finalização de Reports"

'On Error GoTo Error_Handler

'Dim objOutlook As Outlook.Application
'Dim objEmail As Outlook.MailItem

'Set objOutlook = CreateObject("Outlook.Application")
'Set objEmail = objOutlook.CreateItem(olMailItem)

'With objEmail
'.To = ""
'.Subject = ""
'.body = "Seguem em anexo os reports diários. Cumprimentos."
'.Attachments.Add
"\\CASA-103E368BC4\SharedDocs\rpt_info_diarias_Amoreiras.pdf"
'.Attachments.Add
"\\CASA-103E368BC4\SharedDocs\rpt_Orcamentos_Amoreiras.pdf"
'.Attachments.Add
"\\CASA-103E368BC4\SharedDocs\rpt_servicos_diarios_Amoreiras.pdf"
'.Attachments.Add
"\\CASA-103E368BC4\SharedDocs\rpt_vendas_por_produto_Amoreiras.pdf"
'.Attachments.Add
"\\CASA-103E368BC4\SharedDocs\rpt_Caixa_Vista_Directa_Amoreiras.pdf"
'.Attachments.Add
"\\CASA-103E368BC4\SharedDocs\rpt_Despesas_Amoreiras.pdf"
'.Send
'.ReadReceiptRequested
'End With

'Exit_Here:
'Set objOutlook = Nothing
'Exit Function

'Error_Handler:
'MsgBox Err & ": " & Err.Description
'Resume Exit_Here


If Weekday(Now()) = vbSunday Then ' today is sunday
MsgBox "Lembre-se de imprimir os reports semanais.", 48, "Reports
Semanais!"

End If
If Day(Now() + 1) = 1 Then ' today is the last day of the month
MsgBox "Lembre-se de imprimir os reports mensais.", 48, "Reports Mensais!"

End If


End Function
 
I've copied everything so I can look at it is Access. Does it do it on your
machine? Does it still jump into the code window with all of those lines
commented out? Have you tried to comment out the SetWarnings at the
beginning and deal with all of the warnings as a test to see if they are all
expected?
 
I assume you are using Stephan Lebans ConvertReportToPDF() code. Is that
true?
 
I've seen this before. Try this: When the code window opens, do a
recompile and see if you have a syntax error. If not, use the menu FILE |
Close to properly close the code window. Compact/Repair, then try running
the reports again. You may get a legitimate syntax error that you can fix.

HTH, UpRider
 
What I mean is that it still works now. the code runs perfectly, and it does
what it's suposed to do but at the end it shows up the VB Editor window...
:(:(:( Any thoughts??
 
yes.
the question is: this code worked fine before the split was made. why this
behavior now?
 
I'm not sure why it is doing what you describe. To troubleshoot I would just
do as you have been doing and comment out blocks of the code until the
problem goes away and then start bringing it back in until the problem comes
back. Have you event done a /decompile?
http://www.granite.ab.ca/access/decompile.htm
yes.
the question is: this code worked fine before the split was made. why this
behavior now?
I assume you are using Stephan Lebans ConvertReportToPDF() code. Is that
true?
[quoted text clipped - 176 lines]
 
The first release of Access 2000 was particularly
prone to the "invisible break point problem".

Make sure that you have applied all service packs.

Decompile the program file, using the /decompile option.
Make a back up copy first.

(david)
 
Back
Top