Results 1 to 6 of 6
  1. #1
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153

    Exclamation cmdPrint in two different databases, one crashes the database, the other works fine?

    I have a storage database that tracks tenants and payments and rent. I have a report for Payment History and titled the same. However, when the button is pushed, it says "printing to 'theprintersname'" then the database crashes.
    The same code is used for a different database to print a report of the workdays incoming payments for all businesses. (my company has multiple entities within it).
    That report prints just fine!

    The report is bound to a query with the following sql (the parameters are retrieved from an unbound form [which has the print button on it])

    Code:
    SELECT Payment.LeaseID, Tenant.TenantName, [Year] & " - " & [Month] AS PaymentFor, Payment.DateDue, Payment.DatePaid, Payment.AmtDue, Payment.PaymentTypeID, Payment.PaymentCategoryID, Payment.ReferenceNumber, Payment.Amount, Payment.Notes, Payment.PaymentID, Payment.DateAdded, Payment.Balance, Month([DateDue]) AS MonthNum, Year([DateDue]) AS [Year], MonthName([MonthNum],True) AS [Month]
    FROM Tenant INNER JOIN (Lease INNER JOIN Payment ON Lease.LeaseID = Payment.LeaseID) ON Tenant.TenantID = Lease.TenantID
    WHERE (((Payment.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND ((Payment.DateDue)>=[Forms]![SelectLease]![DateFrom] And (Payment.DateDue)<[Forms]![SelectLease]![DateTo]+1) AND ((Lease.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit])) OR (((Payment.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND ((Payment.DateDue)>=[Forms]![SelectLease]![DateFrom] And (Payment.DateDue)<[Forms]![SelectLease]![DateTo]+1) AND (([Forms]![SelectLease]![cboLeaseUnit]) Is Null)) OR (((Payment.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND ((Payment.DateDue)<[Forms]![SelectLease]![DateTo]+1) AND ((Lease.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND (([Forms]![SelectLease]![DateFrom]) Is Null)) OR (((Payment.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND ((Payment.DateDue)<[Forms]![SelectLease]![DateTo]+1) AND (([Forms]![SelectLease]![cboLeaseUnit]) Is Null) AND (([Forms]![SelectLease]![DateFrom]) Is Null)) OR (((Payment.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND ((Payment.DateDue)>=[Forms]![SelectLease]![DateFrom]) AND ((Lease.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND (([Forms]![SelectLease]![DateTo]) Is Null)) OR (((Payment.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND ((Payment.DateDue)>=[Forms]![SelectLease]![DateFrom]) AND (([Forms]![SelectLease]![cboLeaseUnit]) Is Null) AND (([Forms]![SelectLease]![DateTo]) Is Null)) OR (((Lease.LeaseID)=[Forms]![SelectLease]![cboLeaseUnit]) AND (([Forms]![SelectLease]![DateFrom]) Is Null) AND (([Forms]![SelectLease]![DateTo]) Is Null)) OR ((([Forms]![SelectLease]![cboLeaseUnit]) Is Null) AND (([Forms]![SelectLease]![DateFrom]) Is Null) AND (([Forms]![SelectLease]![DateTo]) Is Null))
    ORDER BY Payment.DateDue;
    as you can see there is a TON of criteria.
    this may put it into perspective a bit better

    Click image for larger version. 

Name:	PaymentsHistoryQry.PNG 
Views:	9 
Size:	35.2 KB 
ID:	23014



    The form is a simple unbound form with text boxes for dateto and datefrom and combo boxes for select tenant and select lease
    Click image for larger version. 

Name:	SelectLeaseFormDesign.PNG 
Views:	9 
Size:	11.5 KB 
ID:	23015

    The code behind the report on open event is
    Code:
    Private Sub Report_Open(Cancel As Integer)
    
    Const FORMNOTOPEN = 2450
       
    Dim frm As Form
        
    On Error Resume Next
        
    Set frm = Forms!SelectLease
        
    If Err = FORMNOTOPEN Then
        DoCmd.OpenForm "SelectLease"
        Cancel = True
    Else
        If Err <> 0 Then
            ' unknown error
            MsgBox Err.Description, vbExclamation, "Error"
        End If
    End If
        
    End Sub
    and the code behind the print button is

    Code:
    Private Sub cmdPrint_Click()
    
    Const REPORTCANCELLED = 2501
    
    On Error Resume Next
    
    DoCmd.OpenReport "Payment History", acViewNormal
    
    Select Case Err.Number
        Case 0
        DoCmd.Close acForm, "SelectLease"
        Case REPORTCANCELLED
        MsgBox Err.Description, vbInformation, "Error: Report Cancelled!"
        Case Else
        MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description, vbInformation, "Error:Unknown"
    End Select
    
    End Sub
    I have no idea why it would be crashing the database. I can open the query and type in the parameters via the popup boxes and view it with no problem. I can also view the report by entering in the filter manually in design view and opening the selectlease form in design view then opening the history report normally. It shows the correct data.
    I use the same print button in another database with no problems! I've tried in both access 2013 and 2016. The problem exists with both!
    I'm stumped!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Usually, its not the code that crashes the db, its the PC. I had the same problem with 1 PC. It kept crashing, The Access fix problems function did no effect.

    It was easier to swap out the PC and never had a problem.
    Tho I did not try a full Access removal and reinstall. Its just something in that PC.

  3. #3
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    I've reinstalled and everything no difference. But if it was the pc wouldn't it crash the other database as well?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    no. I had the same program on 2 'same' PCs. 1 worked, 1 crashed.
    Either something got corrupted, or was missing.
    Fresh PC worked.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    In the report, did you define a printer? Maybe the report uses a specific printer, port, name, etc.

    It can be more simple to use the system default printer by avoiding custom settings in the report.

  6. #6
    breakingme10 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Oklahoma
    Posts
    153
    Quote Originally Posted by ranman256 View Post
    no. I had the same program on 2 'same' PCs. 1 worked, 1 crashed.
    Either something got corrupted, or was missing.
    Fresh PC worked.
    Ok your misunderstanding me. The same code is used in two different databases to print a report. Both databases are on the SAME computer. One works. The other crashes it. What your suggesting isn't possible for me. I cannot reinstall my OS.


    In the report, did you define a printer? Maybe the report uses a specific printer, port, name, etc.

    It can be more simple to use the system default printer by avoiding custom settings in the report.
    I think previously I had told it to print to a different printer. But even though I changed it back. It made no difference, I feel like just beating my head against the wall at this point.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-18-2015, 08:02 AM
  2. Replies: 3
    Last Post: 06-20-2015, 10:18 PM
  3. Replies: 2
    Last Post: 12-07-2014, 10:03 PM
  4. Replies: 1
    Last Post: 11-14-2014, 05:12 PM
  5. Replies: 6
    Last Post: 10-15-2014, 02:45 PM

Tags for this Thread

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