By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

I need help with Message box if statements..

P: 1
I need help with the following code.
I am trying to extract two reports at the same time, but I want the viewer to see the report first before exporting it. The reason is in case the report is null. There are two reports, one for 2006 and one for 2007.

Problem is when I tried making a Msgbox if statement, it does not work correctly. I want the user to say "yes or no" to extract report and then continue from there.

I can't get either working. Any help will be apperciated.

If there is a simpler way where I tried to export both reports to a folder but does NOT export null reports (reports with no data) that would even be better.




If (Plan_Year) = "Both Plan Years" Then

stDocName = "Plan Type Checks1"
DoCmd.OpenQuery stDocName, acNormal, acEdit

If MsgBox("Extract Report to Client Folder?", vbYesNo) = vbYes Then

stDocName = "Plan Type Checks1"
stFileName = "X:\Clients\C\CDI\2007\Outsourcing\FSA\ "
stFileName = stFileName & Format(Check_Date, "yyyy-mm-dd") & " " & "CDI 2006 FSA Checks Printed"
stFileName = stFileName & ".xls"
stDocName = "Plan Type Checks1"
DoCmd.OutputTo acOutputQuery, "Plan Type Checks1", acSpreadsheetTypeExcel9, stFileName, False

stDocName = "Plan Type Checks2"
DoCmd.OpenQuery stDocName, acNormal, acEdit

If MsgBox("Extract Report to Client Folder?", vbYesNo) = vbYes Then

stDocName = "Plan Type Checks2"
stFileName = "X:\Clients\C\CDI\2007\Outsourcing\FSA\ "
stFileName = stFileName & Format(Check_Date, "yyyy-mm-dd") & " " & "CDI 2007 FSA Checks Printed"
stFileName = stFileName & ".xls"
stDocName = "Plan Type Checks2"

DoCmd.OutputTo acOutputQuery, "Plan Type Checks2", acSpreadsheetTypeExcel9, stFileName, False

If MsgBox("CDI FSA Check Printed Reports Exported to X:\Clients\C\CDI\2007\Outsourcing\FSA. Go to CDI FSA Report folder?", vbYesNo) = vbYes Then
FollowHyperlink "X:\Clients\C\CDI\2007\Outsourcing\FSA "

End If
Aug 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
I need help with the following code.
I am trying to extract two reports at the same time, but I want the viewer to see the report first before exporting it. The reason is in case the report is null. There are two reports, one for 2006 and one for 2007.

Problem is when I tried making a Msgbox if statement, it does not work correctly. I want the user to say "yes or no" to extract report and then continue from there.

I can't get either working. Any help will be apperciated.

If there is a simpler way where I tried to export both reports to a folder but does NOT export null reports (reports with no data) that would even be better.




If (Plan_Year) = "Both Plan Years" Then

stDocName = "Plan Type Checks1"
DoCmd.OpenQuery stDocName, acNormal, acEdit

If MsgBox("Extract Report to Client Folder?", vbYesNo) = vbYes Then

stDocName = "Plan Type Checks1"
stFileName = "X:\Clients\C\CDI\2007\Outsourcing\FSA\ "
stFileName = stFileName & Format(Check_Date, "yyyy-mm-dd") & " " & "CDI 2006 FSA Checks Printed"
stFileName = stFileName & ".xls"
stDocName = "Plan Type Checks1"
DoCmd.OutputTo acOutputQuery, "Plan Type Checks1", acSpreadsheetTypeExcel9, stFileName, False

stDocName = "Plan Type Checks2"
DoCmd.OpenQuery stDocName, acNormal, acEdit

If MsgBox("Extract Report to Client Folder?", vbYesNo) = vbYes Then

stDocName = "Plan Type Checks2"
stFileName = "X:\Clients\C\CDI\2007\Outsourcing\FSA\ "
stFileName = stFileName & Format(Check_Date, "yyyy-mm-dd") & " " & "CDI 2007 FSA Checks Printed"
stFileName = stFileName & ".xls"
stDocName = "Plan Type Checks2"

DoCmd.OutputTo acOutputQuery, "Plan Type Checks2", acSpreadsheetTypeExcel9, stFileName, False

If MsgBox("CDI FSA Check Printed Reports Exported to X:\Clients\C\CDI\2007\Outsourcing\FSA. Go to CDI FSA Report folder?", vbYesNo) = vbYes Then
FollowHyperlink "X:\Clients\C\CDI\2007\Outsourcing\FSA "

End If
Did you try assigning the return value to a variable, then running the If statement?
Aug 21 '07 #2

kadghar
Expert 100+
P: 1,295
You're not closing the IF statements.
Try closing each IF, or change the IFs, other than the first one with ELSEIF
Aug 21 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.