I have VBA code that is to output 2 reports to snapshot format for emailing. When I add a cancel on the report if no data, the second report will not output even when there is data -
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "QRY_EXPCLNUP", acViewNormal, acEdit
-
DoCmd.OpenQuery "Data File Pull", acViewNormal, acEdit
-
DoCmd.TransferText acExportDelim, "", "TBL_EXPORT", "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.TXT", True, ""
-
DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMATTN.SNP", False, "", 0
-
I am not sure what I amdoing worng, any help?
Thanks
26 5469
I have VBA code that is to output 2 reports to snapshot format for emailing. When I add a cancel on the report if no data, the second report will not output even when there is data -
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "QRY_EXPCLNUP", acViewNormal, acEdit
-
DoCmd.OpenQuery "Data File Pull", acViewNormal, acEdit
-
DoCmd.TransferText acExportDelim, "", "TBL_EXPORT", "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.TXT", True, ""
-
DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMATTN.SNP", False, "", 0
-
I am not sure what I amdoing worng, any help?
Thanks
How are you cancelling the report if no data?
Where does this code reside? Please post the entire sub-routine... (I notice you have set your warnings to false... hopefully later in this section of code you return them to true!)
Regards,
Scott
How are you cancelling the report if no data?
Where does this code reside? Please post the entire sub-routine... (I notice you have set your warnings to false... hopefully later in this section of code you return them to true!)
Regards,
Scott
Scott
The code to execte the out put is a commad buton. The Cancel event is in the "no Data" on hte report. Is this wrong? Should I be handling the Do data thig somewhere else?
Yes the warnings get set back to on at the end of the Select statement.
Thanks
Troy
Scott
The code to execte the out put is a commad buton. The Cancel event is in the "no Data" on hte report. Is this wrong? Should I be handling the Do data thig somewhere else?
Yes the warnings get set back to on at the end of the Select statement.
Thanks
Troy
To get this a little clearer in my mind, how exactly is the Cancel called? I understand that you are doing this is under the On No Data event of the report... My question: is it cancelled through an expression, code, macro?? If code, please post the code used to cancel.
Regards,
Scott
To get this a little clearer in my mind, how exactly is the Cancel called? I understand that you are doing this is under the On No Data event of the report... My question: is it cancelled through an expression, code, macro?? If code, please post the code used to cancel.
Regards,
Scott
Scott
Sorry Scott using the code below - Private Sub Report_NoData(Cancel As Integer)
-
-
On Error GoTo Report_NoDataError
-
-
MsgBox "No records meet the report criteria; cancelling report printing"
-
Cancel = True
-
-
Report_NoDataExit:
-
Exit Sub
-
-
Report_NoDataError:
-
MsgBox Err.Description
-
Resume Report_NoDataExit
-
-
End Sub
-
Thanks for posting that section of code!
Could you now please post the whole procedure for your first section of code?
What I think is happening (not sure yet without seeing all the code...) is that you are calling 2 separate reports/subreports (from your first section of code they would be called MBM Time Sheet, and MBM ATTN Sheet) from within another report/function (from your second section of code this is called Report?)?
Let me know if these assumptions are correct, thanks!
Regards,
Scott
Scott Here is the full code that calls the out put. What I did find interesting is that when I had the cancel event on the "on no data" for the repots, there is code to call both of them to open either in preview or send tothe printer it worksexactly likeI want it to.
Heres the code -
If Nz(Forms![control center]![Report list]) <> "" Then
-
Select Case Forms![control center]![Report list]
-
Case "MBM Time Sheets"
-
Call mbmtimeshts
-
Case "Time Summary"
-
Call timesum
-
Case "Year To Date Managers Chart"
-
Call ytdmgr
-
Case "Vacation Calendar"
-
Call VacCal
-
Case "Seniority Report"
-
Call senority
-
Case "Absenteeism Report"
-
Call attendance
-
Case "Associate List"
-
Call emplist
-
Case "Birthday List"
-
Call bday
-
Case "Cost Center List"
-
Call cclist
-
Case "Punch Card Labels"
-
Call punchcard
-
Case "Associate Phone Book"
-
Call phonebook
-
Case "Year To Date Managers Report"
-
Call ytdrpt
-
Case "Online Vacation Calendar"
-
Call vacchrt
-
Case "Staffing Service Time Sheets"
-
Call Stafftimeshts
-
Case "Entry Verification"
-
Call entryverify
-
Case "Set Up Text File"
-
Call textfile
-
Case "Vacation Calender By Name"
-
Call vaccalstaff
-
End Select
-
-
Else
-
Forms![control center]![Report list].SetFocus
-
Forms![control center]![Report list].Dropdown
-
End If
-
End Function
-
Function mbmtimeshts()
-
'On Error GoTo mbmtimesgts_err
-
DoCmd.SetWarnings False
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM Time Sheet", acPreview, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM Time Sheet", acNormal, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acNormal, "", ""
-
End If
-
'mbmtimesgts_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
-
-
Function timesum()
-
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "Time Summary", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "Time Summary", acNormal, "", ""
-
End If
-
-
End Function
-
-
Function ytdmgr()
-
DoCmd.OpenForm "pvt_ytdchart", acFormPivotTable, "", "", , acNormal
-
End Function
-
-
Function VacCal()
-
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "rpt_calander", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "rpt_calander", acNormal, "", ""
-
End If
-
-
End Function
-
Function senority()
-
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "rpt_SENORITY", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "rpt_SENORITY", acNormal, "", ""
-
End If
-
-
End Function
-
Function attendance()
-
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "RPT_Staff Attendance", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "RPT_Staff Attendance", acNormal, "", ""
-
End If
-
-
End Function
-
-
Function emplist()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "Employee List", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "Employee List", acNormal, "", ""
-
End If
-
End Function
-
-
Function bday()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "rtp_bday", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "rtp_bday", acNormal, "", ""
-
End If
-
End Function
-
-
Function cclist()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "Cost Center List", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "Cost Center List", acNormal, "", ""
-
End If
-
End Function
-
-
Function punchcard()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "Labels punch card print", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "Labels punch card print", acNormal, "", ""
-
End If
-
End Function
-
Function phonebook()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "pHONE bOOK", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "pHONE bOOK", acNormal, "", ""
-
End If
-
End Function
-
Function ytdrpt()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "rpt_YTD MGR SUMMARY", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "rpt_YTD MGR SUMMARY", acNormal, "", ""
-
End If
-
End Function
-
Function vacchrt()
-
DoCmd.OpenForm "NEW VAC", acFormPivotTable, "", "", , acNormal
-
End Function
-
Function Stafftimeshts()
-
On Error GoTo STAFFTIMESHTS_ERR
-
If Forms![control center]![frareportmode] = 1 Then
-
Beep
-
MsgBox "Are You sure You Have Selected the Correct Week of The Pay Period", vbInformation, ""
-
DoCmd.OpenReport "Staff Service Time Sheet", acViewPreview, "", ""
-
DoCmd.OpenReport "Staff Service Time Sheet SB", acViewPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
MsgBox "Are You sure You Have Selected the Correct Week of The Pay Period", vbInformation, ""
-
DoCmd.OpenReport "Staff Service Time Sheet", acNormal, "", ""
-
DoCmd.OpenReport "Staff Service Time Sheet SB", acNormal, "", ""
-
End If
-
STAFFTIMESHTS_ERR:
-
MsgBox ("There are no Records for this Time Period.")
-
Reponse = 0
-
End Function
-
-
Function entryverify()
-
DoCmd.OpenQuery "EMP List Without Matching time summary", acNormal, acEdit
-
End Function
-
Function textfile()
-
Dim strinput As String
-
strinput = "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.txt"
-
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "QRY_EXPCLNUP", acViewNormal, acEdit
-
DoCmd.OpenQuery "Data File Pull", acViewNormal, acEdit
-
DoCmd.TransferText acExportDelim, "", "TBL_EXPORT", "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.TXT", True, ""
-
DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMATTN.SNP", False, "", 0
-
Application.FollowHyperlink strinput, , True
-
-
End Function
-
-
Function vaccalstaff()
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "rpt_calbystaff", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "qry_listreport", acNormal, "", ""
-
End If
-
End Function
-
-
Thanks
Troy
Thanks again for posting the code!
Try changing your first select case statement to add another call function:
I.e after line 4 of your posted code, you would add another line that says
Next, create the function called mbmattnsheet. It will be almost exactly the same as your other functions... This will require changing these lines of code (44 to 59 in your post) -
Function mbmtimeshts()
-
'On Error GoTo mbmtimesgts_err
-
DoCmd.SetWarnings False
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM Time Sheet", acPreview, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM Time Sheet", acNormal, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acNormal, "", ""
-
End If
-
'mbmtimesgts_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
To this: - Function mbmtimeshts()
-
'On Error GoTo mbmtimesgts_err
-
DoCmd.SetWarnings False
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM Time Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM Time Sheet", acNormal, "", ""
-
End If
-
'mbmtimesgts_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
-
-
Function mbmattnsheet()
-
'On Error GoTO mbmattns_err
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM ATTN Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM ATTN Sheet", acNormal, "", ""
-
End If
-
'mbmattns_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
I think what's happening is that when one of your conditions in the existing function is false, then it exits the whole function... Thus splitting it into two functions that are called from the same select case, will still call one even if the other is false...
Let me know if this works!
Regards,
Scott
Thanks again for posting the code!
Try changing your first select case statement to add another call function:
I.e after line 4 of your posted code, you would add another line that says
Next, create the function called mbmattnsheet. It will be almost exactly the same as your other functions... This will require changing these lines of code (44 to 59 in your post) -
Function mbmtimeshts()
-
'On Error GoTo mbmtimesgts_err
-
DoCmd.SetWarnings False
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM Time Sheet", acPreview, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM Time Sheet", acNormal, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acNormal, "", ""
-
End If
-
'mbmtimesgts_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
To this: - Function mbmtimeshts()
-
'On Error GoTo mbmtimesgts_err
-
DoCmd.SetWarnings False
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM Time Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM Time Sheet", acNormal, "", ""
-
End If
-
'mbmtimesgts_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
-
-
Function mbmattnsheet()
-
'On Error GoTO mbmattns_err
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM ATTN Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM ATTN Sheet", acNormal, "", ""
-
End If
-
'mbmattns_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
-
-
End Function
I think what's happening is that when one of your conditions in the existing function is false, then it exits the whole function... Thus splitting it into two functions that are called from the same select case, will still call one even if the other is false...
Let me know if this works!
Regards,
Scott
Scott
Thanks for change but it is in the function called "Function textfile()
" that it stops, The user can choose to print the reports or output them to snap shot. When they try to output them is when it will not export the second report. In the function "Function textfile()", a text files is created and copies of the reports are output to snapshot for emiling. This DB is a processing tool for Timesheets. The text file and snapshots are emiled into our Corp office, the text fiel is autmatically loaded and the snapshots are for verification.
Thanks
Troy[/Qoute]
Scott
Thanks for change but it is in the function called "Function textfile()
" that it stops, The user can choose to print the reports or output them to snap shot. When they try to output them is when it will not export the second report. In the function "Function textfile()", a text files is created and copies of the reports are output to snapshot for emiling. This DB is a processing tool for Timesheets. The text file and snapshots are emiled into our Corp office, the text fiel is autmatically loaded and the snapshots are for verification.
Thanks
Troy[/Qoute]
Try splitting the textfile() function into two parts, similar to the function in my previous suggestion. If this doesn't work for you, please post back.
Regards,
Scott
Try splitting the textfile() function into two parts, similar to the function in my previous suggestion. If this doesn't work for you, please post back.
Regards,
Scott
Thanks Scot for the solution, unfortunity it is still not working, when it runs the first output it gives a error message that there are no records, which it is supposed to do, but even when there are records.
Thanks
Troy
Thanks Scot for the solution, unfortunity it is still not working, when it runs the first output it gives a error message that there are no records, which it is supposed to do, but even when there are records.
Thanks
Troy
I'm thinking, then, that the problem doesn't lie with the functions you posted... Take a good look at the conditions that occur before these functions are called.
If you can track through what happens in what order, you're half way to a solution :-) Especially look at the queries that populate these reports, and any code that runs under command buttons, onopen procedures etc...
Since both refuse to print even though one SHOULD have data in it, logically they have to be tied together somewhere back down the chain of functions, commands, queries, validation code, etc. Track through to where they are tied together, separate them out, and then test again.
Regards,
Scott
Another quick thought, if you are not the original developer of this database... Did the original developer leave a design blueprint laying around somewhere? This could help you track down the problem, especially if there existed/possibly still exists a so-called 'business' rule where someone decided that these two reports should never be printed separately from each other and so required a validation rule to be built in at some point tying them together never to be separated?
Regards,
Scott
Another quick thought, if you are not the original developer of this database... Did the original developer leave a design blueprint laying around somewhere? This could help you track down the problem, especially if there existed/possibly still exists a so-called 'business' rule where someone decided that these two reports should never be printed separately from each other and so required a validation rule to be built in at some point tying them together never to be separated?
Regards,
Scott
Scott
I am the orginal developer of this. The reason for them outputing together is simplfing process for end user. Most of the user are not very eperienced and we are trying t make this as simple as we can. I am wondering if i should be using a an IIF statement in the code to call the out put, ie checking for data before it even calls the report to output? Ideas?
Thanks
Troy
Scott
I am the orginal developer of this. The reason for them outputing together is simplfing process for end user. Most of the user are not very eperienced and we are trying t make this as simple as we can. I am wondering if i should be using a an IIF statement in the code to call the out put, ie checking for data before it even calls the report to output? Ideas?
Thanks
Troy
Well, you certainly could use an IIF statement, just keep in mind when using the iif structure in vba code that it can at times negatively affect your performance, because vba evaluates BOTH the value if true and the value if false statements, even though it only returns one of them. Perhaps better to use an If Not Isnull()...Then, or an If IsNull()...Then structure when programming this in vba. That said, I have used it myself, and will continue to use it in vba code when performance is not an issue.
(Note the iif statement doesn't result in the same performance problems when used in queries, can't just tell you exactly why not at the moment, but if you are interested in the intricacies of it, I think there's some good info on this site in the articles section that addresses the issue.)
It's still intriguing that your two reports won't fire independently of each other. As I said in a previous post, logically they HAVE to be tied together somewhere down the chain, either intentionally or unintentionally.
Anyway, let me know how it goes!
Regards,
Scott
Well, you certainly could use an IIF statement, just keep in mind when using the iif structure in vba code that it can at times negatively affect your performance, because vba evaluates BOTH the value if true and the value if false statements, even though it only returns one of them. Perhaps better to use an If Not Isnull()...Then, or an If IsNull()...Then structure when programming this in vba. That said, I have used it myself, and will continue to use it in vba code when performance is not an issue.
(Note the iif statement doesn't result in the same performance problems when used in queries, can't just tell you exactly why not at the moment, but if you are interested in the intricacies of it, I think there's some good info on this site in the articles section that addresses the issue.)
It's still intriguing that your two reports won't fire independently of each other. As I said in a previous post, logically they HAVE to be tied together somewhere down the chain, either intentionally or unintentionally.
Anyway, let me know how it goes!
Regards,
Scott
Scott
I have them both outputing but even when there is data in both the second report will not have anything in it even when there is data there. I can't find anyhting that would tie teh 2 together except that tehy both come from the same data table. Coul dthat be something?
Thanks
Troy
Scott
I have them both outputing but even when there is data in both the second report will not have anything in it even when there is data there. I can't find anyhting that would tie teh 2 together except that tehy both come from the same data table. Coul dthat be something?
Thanks
Troy
I guess we've focused so much on the vb code, I haven't even thought to ask this question :-(
Are they based on one query, or two?
If two, have you run them separately to make sure they return the data they should?
If one, you should split them, eh?
Regards,
Scott
I guess we've focused so much on the vb code, I haven't even thought to ask this question :-(
Are they based on one query, or two?
If two, have you run them separately to make sure they return the data they should?
If one, you should split them, eh?
Regards,
Scott
Scot
The data for both reports is in the same table, there is a set up query and then sthere are 2 different queries that generate each report. Coul dit be the set up query ?
Thanks
Troy
Scot
The data for both reports is in the same table, there is a set up query and then sthere are 2 different queries that generate each report. Coul dit be the set up query ?
Thanks
Troy
I'd like to say yes!
Try running the setup query while replicating the situation that produces no data for the one report. If it returns no data, then you've got your answer about where the two are tied together, intentionally or un- .
On another line, do you really NEED the setup query? Can you simply base both off the same table?
Regards,
Scott
I'd like to say yes!
Try running the setup query while replicating the situation that produces no data for the one report. If it returns no data, then you've got your answer about where the two are tied together, intentionally or un- .
On another line, do you really NEED the setup query? Can you simply base both off the same table?
Regards,
Scott
Scott
I tried this and the queries run fine. everything seems to run fine except when i try to output in code.
I dont know anymore.
Troy
Scott
I tried this and the queries run fine. everything seems to run fine except when i try to output in code.
I dont know anymore.
Troy
Just looking back over this thread to see what I've missed!! I noticed this time looking at these lines of code that your function msmtimeshts is dependent on something called frareportmode = 1. Have we established what the criteria might be for making this statement true, and therefore calling the function and outputting the reports? - Function mbmtimeshts()
-
'On Error GoTo mbmtimesgts_err
-
DoCmd.SetWarnings False
-
If Forms![control center]![frareportmode] = 1 Then
-
DoCmd.OpenReport "MBM Time Sheet", acPreview, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acPreview, "", ""
-
ElseIf Forms![control center]![frareportmode] = 2 Then
-
DoCmd.OpenReport "MBM Time Sheet", acNormal, "", ""
-
DoCmd.OpenReport "MBM ATTN Sheet", acNormal, "", ""
-
End If
-
'mbmtimesgts_err:
-
-
'MsgBox ("There are no Records for this Time Period.")
-
'Reponse = 0
Regards,
Scott
Have you tried to just use and if/then statment around the code for the reports
If <> Null then
Run Report1
end if
if <> Null then
Run Report2
end if
Have you tried to just use and if/then statment around the code for the reports
If <> Null then
Run Report1
end if
if <> Null then
Run Report2
end if
Scott
The function that references "frareportmode = 1" is a difference funcrion. THat is how they can either preview or print reports.
The error is occurring in -
Function textfile()
-
Dim strinput As String
-
strinput = "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.txt"
-
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "QRY_EXPCLNUP", acViewNormal, acEdit
-
DoCmd.OpenQuery "Data File Pull", acViewNormal, acEdit
-
DoCmd.TransferText acExportDelim, "", "TBL_EXPORT", "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.TXT", True, ""
-
DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMATTN.SNP", False, "", 0
-
Application.FollowHyperlink strinput, , True
-
-
End Function
-
Thats why i can seem to understand why his is not working. If you Preview or print the reports they work fine. if you select tooutput them to snapshot they dont.
Thanks
Troy
Troy, bear with me here... I'm having senior moments I think.
The syntax of your output commands might be what's holding you up:
Instead of this: - DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)",
Try this: - DoCmd.OutputTo acOutputReport, "MBM Time Sheet", acFormatSNP
-
The rest of your code there should be all right... (I just replaced the part of the code line that looked like it needed a bit of different syntax)
Regards,
Scott
P.S. If this still doesn't work, try changing the acFormatSNP to "Snapshot Format"
Troy, bear with me here... I'm having senior moments I think.
The syntax of your output commands might be what's holding you up:
Instead of this: - DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)",
Try this: - DoCmd.OutputTo acOutputReport, "MBM Time Sheet", acFormatSNP
-
The rest of your code there should be all right... (I just replaced the part of the code line that looked like it needed a bit of different syntax)
Regards,
Scott
P.S. If this still doesn't work, try changing the acFormatSNP to "Snapshot Format"
Scott
Still no go! I tried both
The code will still output the report but it will be blank, it wont even have the dates anything just the lay out with out data. it like it cant find the data for the second report.
Thanks
Troy
Scott
Still no go! I tried both
The code will still output the report but it will be blank, it wont even have the dates anything just the lay out with out data. it like it cant find the data for the second report.
Thanks
Troy
The only other thing I can think of is to delete the 0 from the end of your DoCmd.Output code. That just specifies an encoding format, which I don't think you really need nor want.
Regards,
Scott
p.s. I also PM'ed an expert to take a look at this to see what I'm missing!
I have VBA code that is to output 2 reports to snapshot format for emailing. When I add a cancel on the report if no data, the second report will not output even when there is data -
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "QRY_EXPCLNUP", acViewNormal, acEdit
-
DoCmd.OpenQuery "Data File Pull", acViewNormal, acEdit
-
DoCmd.TransferText acExportDelim, "", "TBL_EXPORT", "C:\Account Tools\Payroll\EXPORT\TIMESHEETINFO.TXT", True, ""
-
DoCmd.OutputTo acReport, "MBM Time Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMTIMESHEET.SNP", False, "", 0
-
DoCmd.OutputTo acReport, "MBM ATTN Sheet", "SnapshotFormat(*.snp)", "C:\Account Tools\Payroll\EXPORT\MBMATTN.SNP", False, "", 0
-
I am not sure what I amdoing worng, any help?
Thanks
If both Reports open successfully independently of each other, rather than setting the Cancel Parameter to True in the NoData() Event, when no data exists, check and see if Records are present by examing the RecordSource of the Report, then proceed from there.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: - Steve - |
last post by:
How do you do the following?
if(true)
response.write "There was a problem."
***STOP HERE***
more code
more code
more code
|
by: Ken Williams |
last post by:
I made a web app, some form data is posted to a report.html that makes changes
to a database. if the user does this and views the report, and then refreshes
the web page the same information and...
|
by: Niyazi |
last post by:
Hi,
I created application that I get information from AS400 for reporting.
In main.exe has only 1 frm which calls (as a class library) CLS_MAIN.dll.
The CLS_MAIN.dll get the tables from AS400...
|
by: Dan Kimhi |
last post by:
I'm using the following lines to output a Crystal Report object to a
webForm:
Dim s As System.IO.MemoryStream =
cr.ExportToStream(CrystalDecisions.Shared].ExportFormatType.PortableDocFormat)...
|
by: sara |
last post by:
Hi -
I have a button that runs 2 reports. If there is no data on the
report, I use the No Data event, and tell the user, and Cancel the
execution of that report.
However, if the first report...
|
by: Phil Stanton |
last post by:
I am running a query that calls a function used to format addresses
depending on the width of a control on a report that shows that address. The
same query is used as the RecordSource of lots of...
|
by: melodyrae |
last post by:
Initial disclosure: I took 1 accounting with access class in undergrad 6 yrs ago, where we were offered step-by-step instructions to follow. Currently, I am interning (grad-school) for a small...
|
by: kcdoell |
last post by:
Hello:
What is the best way to stop a report from running if the query is empty? Currently, I have a form that has a command button on it. The user has to make selections from 3 combo boxes on...
|
by: Phil Stanton |
last post by:
I am opening a report (in Preview) from a menu system
I use the following code if there is no data in a report
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There are no errors in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |