• Expected End of Statement?

    • This topic has 3 replies, 3 voices, and was last updated 24 years ago.
    Author
    Topic
    #355455

    Hi,

    Below is a snipet of code I’m working on.

    My idea: I would like to take a table add a date to the name of the table then export it to Excel.

    Everything seems to be fine, except I continue to get this msg “COMPILE ERROR–Expected: End of Statement”. This part of the code is highlighted when the error occurs (“PH_Labor”

    Code:Dim strDate As Date
    strDate = Date – WeekDay(Date – 6) – 14

    ‘ DoCmd.OutputTo acTable, “PH_Labor”, acFormatXLS,”G:UsersProjschdHistory ArchivesArchive History Lab(“PH_Labor” & strDate.xls) “, True

    Can someone please tell me why?

    Thanks,

    Roberta Newton

    Viewing 0 reply threads
    Author
    Replies
    • #524296

      A couple of obvious things you are trying to save a file name with / in, so that wont be acceptable plus you are trying to turn a date variable into a string.

      Try:-

      Dim strDate As Date
      Dim MrVar As String

      strDate = Date – WeekDay(Date – 6) – 14
      MrVar = Format(strDate, “DDMMYY”) & “.xls”

      DoCmd.OutputTo acTable, “PH_Labor”, acFormatXLS,”G:UsersProjschdHistory ArchivesArchive History Lab(“& “PH_Labor” & strDate &”) “, True

      • #524300

        Ok…I tried that and got the following msg.

        “Labor and Expense History can’t save output date to the the file you’ve selected…….”

        I tried this:

        DoCmd.OutputTo acTable, “PH_Labor”, acFormatXLS, “G:UsersProjschdHistory ArchivesArchive History LabPH_Labor & strDate.xls “, True

        and it works…but puts the name as “PH_Labor & strDate but should be “PH_LABOR4/6/01”. The () around PH_Labor….combines the NAME and strDate.

        This works for renaming purposes…but not for Output purposes?????

        • #524338

          I think that what you want is:

          DoCmd.OutputTo acTable, "PH_Labor", acFormatXLS, "G:UsersProjschdHistory ArchivesArchive HistoryLabPH_Labor" & strDate & ".xls", True
          
    Viewing 0 reply threads
    Reply To: Expected End of Statement?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: