Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Posts
    26

    Unanswered: strSQL statement doesn't seem to be working

    I am trying to view reports selected from a table. When I execute this command however, I get a run-time error '2103' The report name 'select report.[report name] from report where (((report.[in])=Yes));' you entered in either the property sheet or macro is misspelled or refers to report that doesn't exist. What am I doing wrong here?




    Private Sub Command7_Click()

    Dim dbs As Database
    Dim strSQL As String
    Dim rst As Recordset




    Set dbs = CurrentDb()
    strSQL = "SELECT Report.[Report Name] " & _
    " FROM Report " & _
    " WHERE (((Report.[In])=Yes));"

    Set rst = dbs.OpenRecordset(strSQL)
    DoCmd.OpenReport strSQL, acViewPreview


    End Sub

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Betty2 - welcome to the forum

    To simplfy things, what happens if you try:

    Code:
    strSQL = "SELECT [Report Name] " & _
    " FROM [Report] " & _
    " WHERE [In] = Yes"
    I've removed some redundant stuff and enclosed Report in sqare brackets as it may (not certain) be a reserved word.

    Any joy?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2006
    Posts
    26

    same error

    Still getting the same error. I tried changing the name of the table, but still get the same error

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Betty2
    DoCmd.OpenReport strSQL, acViewPreview
    Ooooohhhhhhh. You want to do:
    Code:
    DoCmd.OpenReport rst(0), acViewPreview
    Soz - missed the crucial last line - thought the problem was with the SQL
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2006
    Posts
    26
    Many Thanks!! What if I have more than one report?

  6. #6
    Join Date
    Feb 2006
    Posts
    26
    never mind I got it

Posting Permissions

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