Results 1 to 9 of 9

Run time error '3071' on open report vba code

Threaded View

jeskit Run time error '3071' on open... 06-08-2012, 10:39 AM
JosephP Re: Run time error '3071' on... 06-09-2012, 04:30 PM
alansidman Re: Run time error '3071' on... 06-09-2012, 05:14 PM
jeskit Re: Run time error '3071' on... 06-11-2012, 03:56 AM
JosephP Re: Run time error '3071' on... 06-11-2012, 04:02 AM
jeskit Re: Run time error '3071' on... 06-11-2012, 04:16 AM
jeskit Re: Run time error '3071' on... 06-11-2012, 04:23 AM
JosephP Re: Run time error '3071' on... 06-11-2012, 05:01 AM
jeskit Re: Run time error '3071' on... 06-11-2012, 05:06 AM
  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Run time error '3071' on open report vba code

    Hi,

    I have written a macro in Access VBA which executes a DCount on a query and if the DCount is above 1 it opens and prints a report. However when it gets to the line of code which opens the report it stops and debugs producing an error of "run time error 3071: This expression is typed incorrectly, or it is too complex to be evaluated"

    The code I have created is below and I have highlighted the line it debugs on in red:
    Dim ref As String
    Dim ref2 As String
    Dim strSQL As String
    
    Set db = CurrentDb()
    ref = Me.Text22.Value
    strSQL = DCount("ReBoxed", "Files", "ReBoxed = " & ref)
    ref2 = strSQL
    If ref2 > 1 Then
        DoCmd.OpenReport "Reboxed", acViewPreview
    End If
    I have tried reducing it because at first I had
    DoCmd.OpenReport "Reboxed", acViewPreview,,,acWindowNormal
    However it kept producing that error.Does anyone know why it keeps debugging on that line?

    Thanks,

    jeskit
    Last edited by jeskit; 06-11-2012 at 05:06 AM.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1