×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DoCmd.OpenReport Hangs when user wants to select location of report to save to

DoCmd.OpenReport Hangs when user wants to select location of report to save to

DoCmd.OpenReport Hangs when user wants to select location of report to save to

(OP)
Hi
I am new to this forum and also to vba programming. I need help urgently.

Have developed a program using MS Access. It was working well until lately my machine was upgraded with Office 360.

Somehow when I try to print report with the code below, the command window will open to prompt user to select a location to save the report, and after that it hangs....and I have to kill the task through task manager.

'string value to pass in to the report in Ms Access.
strCriteriaToRpt = "7372Z"
DoCmd.OpenReport "View Remarks of Students", acViewNormal, , strCriteriaToRpt

However, if I were to change the program to the code below, the user will not be allowed to choose the location to save the report, but instead system will save the report to the location that I have specified. And the program works fine.

DoCmd.OpenReport "View Remarks of Students", acViewPreview, , strCriteriaToRpt
MyPath = "D:\SIS\Report_" & strStudentID & ".pdf"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath, False

Can someone enlightened me how I can resolve the problem above? Appreciate.

RE: DoCmd.OpenReport Hangs when user wants to select location of report to save to

Have you considered:

CODE

Private Sub Whatever()
...
DoCmd.OpenReport "View Remarks of Students", acViewPreview, , strCriteriaToRpt
MyPath = GetFolder & "\Report_" & strStudentID & ".pdf"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath, False
...
End Sub

Function GetFolder() As String
    Dim fldr As FileDialog
    Dim sItem As String
    Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
    With fldr
        .Title = "Select a Folder"
        .AllowMultiSelect = False
        .InitialFileName = Application.DefaultFilePath
        If .Show <> -1 Then GoTo NextCode
        sItem = .SelectedItems(1)
    End With
NextCode:
    GetFolder = sItem
    Set fldr = Nothing
End Function 

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: DoCmd.OpenReport Hangs when user wants to select location of report to save to

(OP)
Thank you so much Andy, I'll give it a try. Appreciate.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close