Issue to table name

Peter_1985 1,831 Reputation points
2021-05-05T08:30:27.033+00:00

Hi,
Why is there error
93922-1j.png
due to this line

Set rs = db.openrecordset("select * from " & ActiveSheet.Name & ";")

while ActiveSheet.Name is having value like "Week8-13"?

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
729 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Olaf Helper 25,901 Reputation points
    2021-05-05T08:38:17.393+00:00

    If the sheet name includes some non alphabetical characters you have to set it in square bracket [ ]; better set it always in brackets

    Set rs = db.openrecordset("select * from [" & ActiveSheet.Name & "];")
    
    No comments

  2. Peter_1985 1,831 Reputation points
    2021-05-05T08:41:43.697+00:00

    Sorry, II still have same error using line below

    Set rs = db.openrecordset("select * from [" & ActiveSheet.Name & "];")


  3. Peter_1985 1,831 Reputation points
    2021-05-05T09:05:43.707+00:00
    No comments

  4. Peter_1985 1,831 Reputation points
    2021-05-05T09:22:49.227+00:00

    Does your Access database include a table, which is called “Week8-13”?

    Yes

    No comments

  5. DBG 2,301 Reputation points
    2021-05-05T15:12:22.817+00:00

    This thread may be related to this other one.

    issue-to-code-1.html

    No comments