I have Access from Microsoft 365 and havinga query problem

Anonymous
2025-05-25T01:04:49+00:00

I have Access from Microsoft 365, I am creating a query, and when I try to save it the error:

Characters found after end of SQL statement.

I have tried to find the error and can't run a debug because it hasn't been saved. How can I debug to find the error?

This SQL statement converts the signal-hour fields into universal UTC military time.

Please delete my post. I am taking another option. Thank you all for your help. I need more education in Access before taking on this type of project.

Thanks again, Jerry

Microsoft 365 and Office | Access | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

22 answers

Sort by: Most helpful
  1. DBG 11,381 Reputation points Volunteer Moderator
    2025-05-25T01:24:45+00:00

    Can you post the query's SQL statement? Maybe we can spot the problem.

    0 comments No comments
  2. Anonymous
    2025-05-25T02:39:02+00:00

    Do you want the entire SQL? I will if it helps.

    0 comments No comments
  3. George Hepworth 21,805 Reputation points Volunteer Moderator
    2025-05-25T02:45:36+00:00

    Yes, the entire SQL statement is useful.

    The more information you provide, the higher the probability that someone can offer useful suggestions.

    Open the query in SQL view and copy it completely. The error message indicates that the problem is at the end, but the whole SQL statement provides context.

    Thank you.

    0 comments No comments
  4. Anonymous
    2025-05-25T02:49:24+00:00

    Here it is

    [if gte mso 9]> [endif] [if gte mso 9] Normal 0 false false false EN-US X-NONE X-NONE [endif][if gte mso 9] [endif] [endif] StartFragment

    SELECT [Monday Only].*,

    DateAdd("h", [UCTOffset], [Mon 0000]) AS UniversalMon0000,

    DateAdd("h", [UCTOffset], [Mon 0100]) AS UniversalMon0100,

    DateAdd("h", [UCTOffset], [Mon 0200]) AS UniversalMon0200,

    DateAdd("h", [UCTOffset], [Mon 0300]) AS UniversalMon0300,

    DateAdd("h", [UCTOffset], [Mon 0400]) AS UniversalMon0400,

    DateAdd("h", [UCTOffset], [Mon 0500]) AS UniversalMon0500,

    DateAdd("h", [UCTOffset], [Mon 0600]) AS UniversalMon0600,

    DateAdd("h", [UCTOffset], [Mon 0700]) AS UniversalMon0700,

    DateAdd("h", [UCTOffset], [Mon 0800]) AS UniversalMon0800,

    DateAdd("h", [UCTOffset], [Mon 0900]) AS UniversalMon0900,

    DateAdd("h", [UCTOffset], [Mon 1000]) AS UniversalMon1000,

    DateAdd("h", [UCTOffset], [Mon 1100]) AS UniversalMon1100,

    DateAdd("h", [UCTOffset], [Mon 1200]) AS UniversalMon1200,

    DateAdd("h", [UCTOffset], [Mon 1300]) AS UniversalMon1300,

    DateAdd("h", [UCTOffset], [Mon 1400]) AS UniversalMon1400,

    DateAdd("h", [UCTOffset], [Mon 1500]) AS UniversalMon1500,

    DateAdd("h", [UCTOffset], [Mon 1600]) AS UniversalMon1600,

    DateAdd("h", [UCTOffset], [Mon 1700]) AS UniversalMon1700,

    DateAdd("h", [UCTOffset], [Mon 1800]) AS UniversalMon1800,

    DateAdd("h", [UCTOffset], [Mon 1900]) AS UniversalMon1900,

    DateAdd("h", [UCTOffset], [Mon 2000]) AS UniversalMon2000,

    DateAdd("h", [UCTOffset], [Mon 2100]) AS UniversalMon2100,

    DateAdd("h", [UCTOffset], [Mon 2200]) AS UniversalMon2200,

    DateAdd("h", [UCTOffset], [Mon 2300]) AS UniversalMon2300

    INTO [Monday Only Converted]

    FROM [Monday Only];

    Debug.Print strSQL

    Sub GenerateMondayQuery()

        Dim db As DAO.Database

        Dim strSQL As String

        Dim tableName As String

        Dim newTableName As String

        Dim timeFields As Variant

        Dim i As Integer

        Set table names

        tableName = "[Monday Only]"

        newTableName = "[Monday Only Converted]"

        Define time fields in an array

        timeFields = Array("Mon 0000", "Mon 0100", "Mon 0200", "Mon 0300", "Mon 0400", _

                           "Mon 0500", "Mon 0600", "Mon 0700", "Mon 0800", "Mon 0900", _

                           "Mon 1000", "Mon 1100", "Mon 1200", "Mon 1300", "Mon 1400", _

                         "Mon 1500", "Mon 1600", "Mon 1700", "Mon 1800", "Mon 1900", _

                           "Mon 2000", "Mon 2100", "Mon 2200", "Mon 2300")

        strSQL = strSQL & " INTO [Monday Only Converted] FROM [Monday Only];"

        Loop through fields

        For i = LBound(timeFields) To UBound(timeFields)

        strSQL = strSQL & "DateAdd('h', [UCTOffset], [" & timeFields(i) & "]) AS Universal" & Replace(timeFields(i), " ", "") & ", "

        Next i

        Remove trailing comma

        strSQL = Left(strSQL, Len(strSQL) - 2)

        Add INTO clause

        strSQL = strSQL & " INTO [Monday Only Converted] FROM [Monday Only];"

        Execute query

        Set db = CurrentDb

        db.Execute strSQL, dbFailOnError

    MsgBox "Table '" & [Monday Only Converted] & "' created successfully!", vbInformation, "Success"

    End Sub

    0 comments No comments
  5. Anonymous
    2025-05-25T03:10:48+00:00

    This statement was not part of my copied data:

    StartFragmentif gte mso 9]> [endif] [if gte mso 9] Normal 0 false false false EN-US X-NONE X-NONE [endif][if gte mso 9] [endif] [endif] StartFragmentEndFragment

    Because I could not close my query, I had to copy and paste it into a Word document and paste it to you.

    thank Jerry

    0 comments No comments