Results 1 to 4 of 4
  1. #1
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212

    Problem with this code

    I am using this code in an Access 2000 database. Some 2007 systems have no problem with it. At least one does.

    Could anyone suggest changes to make it more compatible.

    It does not like the DoCmd



    Code:
    Private Sub Form_Load()
       If Forms!CloseForm.cdmarker = "cd" Then
          Dim Response As VbMsgBoxResult
          Response = MsgBox("Do you want to print ClosingDisclosure Pages 2a?", vbQuestion + vbYesNo)
          Application.Echo False
          If Response = vbYes Then DoCmd.OpenReport "Rcdpage2aReport", acViewNormal
          Application.Echo True
       End If
       If Forms!CloseForm.cdmarker = "cd" Then
          Response = MsgBox("Do you want to print ClosingDisclosure Pages 2a Seller Only?", vbQuestion + vbYesNo)
          Application.Echo False
          If Response = vbYes Then DoCmd.OpenReport "Rcdpage2aReportSellerOnly", acViewNormal
          Application.Echo True
       End If
       If Forms!CloseForm.cdmarker = "cd" Then
          Response = MsgBox("Do you want to print ClosingDisclosure Pages 2a Buyer Only?", vbQuestion + vbYesNo)
          Application.Echo False
          If Response = vbYes Then DoCmd.OpenReport "Rcdpage2aReportBuyerOnly", acViewNormal
          Application.Echo True
       End If
    End Sub

    Run-time error '-2147220973 (80040213)':
    Thanks for any help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Which line triggers the error? Provide full error message.

    The Dim statement should be outside the If Then - just below the Sub declaration.

    Should user have opportunity to print all 3 or only 1?

    Consider these revisions of your code:

    Code:
    Private Sub Form_Load()
    If Me.cdmarker = "cd" Then
        If MsgBox("Do you want to print ClosingDisclosure Pages 2a?", vbQuestion + vbYesNo) = vbYes Then
            DoCmd.OpenReport "Rcdpage2aReport", acViewNormal
        End If
        If MsgBox("Do you want to print ClosingDisclosure Pages 2a Seller Only?", vbQuestion + vbYesNo) = vbYes Then
            DoCmd.OpenReport "Rcdpage2aReportSellerOnly", acViewNormal
        End If
        If MsgBox("Do you want to print ClosingDisclosure Pages 2a Buyer Only?", vbQuestion + vbYesNo) = vbYes Then
            DoCmd.OpenReport "Rcdpage2aReportBuyerOnly", acViewNormal
        End If
    End If
    End Sub
    Code:
    Private Sub Form_Load()
    If Forms!CloseForm.cdmarker = "cd" Then
        If MsgBox("Do you want to print ClosingDisclosure Pages 2a?", vbQuestion + vbYesNo) = vbYes Then
            DoCmd.OpenReport "Rcdpage2aReport", acViewNormal
        ElseIf MsgBox("Do you want to print ClosingDisclosure Pages 2a Seller Only?", vbQuestion + vbYesNo) = vbYes Then
            DoCmd.OpenReport "Rcdpage2aReportSellerOnly", acViewNormal
        ElseIf MsgBox("Do you want to print ClosingDisclosure Pages 2a Buyer Only?", vbQuestion + vbYesNo) = vbYes Then
            DoCmd.OpenReport "Rcdpage2aReportBuyerOnly", acViewNormal
       End If
    End Sub
    I have never used Application.Echo.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Generally the user would only want to print one of the three. So your second version of the code is better for the user. Thanks for that.

    The highlighted code was DoCmd.OpenReport (I can't replicate so would have to go back to user).

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I can see no reason for that code to error.

    Need full error message.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Problem with code.
    By gstylianou in forum Access
    Replies: 3
    Last Post: 09-10-2014, 05:15 PM
  2. Code problem
    By sboelitz in forum Programming
    Replies: 1
    Last Post: 06-15-2012, 08:35 AM
  3. Problem with Code
    By jackiea in forum Programming
    Replies: 1
    Last Post: 10-07-2011, 05:59 PM
  4. Code Problem
    By Jeddell in forum Programming
    Replies: 2
    Last Post: 09-29-2011, 06:31 PM
  5. Problem with Code
    By cujee75 in forum Programming
    Replies: 0
    Last Post: 03-10-2006, 02:40 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