Results 1 to 5 of 5
  1. #1
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85

    Unhappy Microsoft Error Message when using Preview/Print buttons

    Click image for larger version. 

Name:	Error.JPG 
Views:	6 
Size:	27.1 KB 
ID:	18288 I have a database that uses the Preview and Print buttons that are available in Access 2003. The database is on a server used by 5 different locations. 4 of the locations can preview and print perfectly but the 5th location gets the attached messaged every time she tries to Preview or Print. She has no problems previewing or printing from the other databases I've set up, only this one. We've checked her printer - it seems to be fine. I did notice that when she tries to print and gets the error message, the program shuts down, but the "databasename".ldb file that opens when you open a database, stays open after the shutdown. You have to close it manually.

    Again, ALL other locations work just fine in the exact same database. I'm copying my code below. Is there anything that anyone can see that would conflict with a Xerox printer in this code - or has anyone else ever had this happen?

    Option Compare Database
    Option Explicit
    Private Sub cmdOpenReport_Click()
    On Error GoTo Err_cmdOpenReport_Click
    Dim strWhere As String
    Dim ctl As Control
    Dim varItem As Variant
    'make sure a selection has been made
    If Me.lstLocation.ItemsSelected.Count = 0 Then
    MsgBox "Must select at least 1 Location"
    Exit Sub
    End If
    'add selected values to string
    Set ctl = Me.lstLocation
    For Each varItem In ctl.ItemsSelected
    strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
    Next varItem
    'trim trailing comma
    strWhere = Left(strWhere, Len(strWhere) - 1)
    'open the report, restricted to the selected items

    Dim strOtherWhere As String


    Dim Otherctl As Control
    Dim OthervarItem As Variant
    'make sure a selection has been made
    If Me.lstSeason.ItemsSelected.Count = 0 Then
    MsgBox "Must select at least 1 Season"
    Exit Sub
    End If
    'add selected values to string
    Set Otherctl = Me.lstSeason
    For Each OthervarItem In Otherctl.ItemsSelected
    strOtherWhere = strOtherWhere & "'" & Otherctl.ItemData(OthervarItem) & "',"
    Next OthervarItem
    'trim trailing comma
    strOtherWhere = Left(strOtherWhere, Len(strOtherWhere) - 1)
    DoCmd.OpenReport "HarvestingSummary", acPreview, , "Location IN(" & strWhere & ") AND Season IN(" & strOtherWhere & ")"
    Exit_cmdOpenReport_Click:
    Exit Sub
    Err_cmdOpenReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenReport_Click
    End Sub

    Private Sub cmdPrintReport_Click()
    On Error GoTo Err_cmdPrintReport_Click

    Dim strWhere As String
    Dim ctl As Control
    Dim varItem As Variant
    'make sure a selection has been made
    If Me.lstLocation.ItemsSelected.Count = 0 Then
    MsgBox "Must select at least 1 Location"
    Exit Sub
    End If
    'add selected values to string
    Set ctl = Me.lstLocation
    For Each varItem In ctl.ItemsSelected
    strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
    Next varItem
    'trim trailing comma
    strWhere = Left(strWhere, Len(strWhere) - 1)
    'open the report, restricted to the selected items

    Dim strOtherWhere As String
    Dim Otherctl As Control
    Dim OthervarItem As Variant
    'make sure a selection has been made
    If Me.lstSeason.ItemsSelected.Count = 0 Then
    MsgBox "Must select at least 1 Season"
    Exit Sub
    End If
    'add selected values to string
    Set Otherctl = Me.lstSeason
    For Each OthervarItem In Otherctl.ItemsSelected
    strOtherWhere = strOtherWhere & "'" & Otherctl.ItemData(OthervarItem) & "',"
    Next OthervarItem
    'trim trailing comma
    strOtherWhere = Left(strOtherWhere, Len(strOtherWhere) - 1)
    DoCmd.OpenReport "HarvestingSummary", acNormal, , "Location IN(" & strWhere & ") AND Season IN(" & strOtherWhere & ")"
    Exit_cmdPrintReport_Click:
    Exit Sub
    Err_cmdPrintReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintReport_Click
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    8,278
    Thats bad, when code crashes Access. Usu you cant stop it.

    Put a stop at the 1st line of the code (F9)
    then step thru the code until it crashs to find the line. F8

    If this doesnt work, compress/repair the db
    create a new blank db,
    then import all the objects. (tables, forms, reports, code, etc)

    The USUALLY fixes the crash problem

  3. #3
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85
    But why is it crashing on only ONE of 5 locations.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,949
    Quote Originally Posted by jparker1954 View Post
    But why is it crashing on only ONE of 5 locations.
    Missing References? Different Access Update? Different Windows Update?

    Is this app Split into a Back End/Front End configuration, with each user having a copy of the Front End on their hard drive, as it should be?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85
    Updates may be an issue. Each computer location has it's own copy of MS Access installed. Each location enters their information into a separate database, we'll call them db1,db2,db3,db4,db5, then the data is uploaded into the MasterDB and printed from there. All these databases are one the same server, but the db1 etal. are in a different directory than the Master DB. This part of the entire system works like a charm for ALL 5 locations. The ONLY thing that doesn't work is that Location 5 can't preview/print the final report. All other connections and locations work great!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-29-2014, 01:05 PM
  2. Replies: 6
    Last Post: 03-01-2014, 07:07 AM
  3. Replies: 1
    Last Post: 01-29-2013, 10:24 AM
  4. Print Preview Margins error
    By yes sir in forum Access
    Replies: 2
    Last Post: 09-15-2010, 05:52 PM
  5. Error when trying to print or print preview
    By TriAdX in forum Reports
    Replies: 8
    Last Post: 08-25-2009, 08:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums