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. Anonymous
    2025-05-25T23:48:01+00:00

    Can you give me a few lines of code to explain your observation?

    It would take more than a few lines of code, I'm afraid.  Firstly, I think you need to work at getting a better understanding of how relational databases work.  You might like to take a look at DatabaseBasics.zip in my Dropbox public databases folder at: 

    https://www.dropbox.com/scl/fo/0scigd3r48hx5xrev2jrf/AB0-GMdTgMAO5O1cGdr3QW0?rlkey=ib6bs6g9jqcrywwzivur3265t&dl=0 

    This little demo file, as its name implies, is designed to give a simple introduction to the database relational model, how it is implemented by means of a set of correctly normalized related tables, and how these are reflected in the user interface of forms and subforms. 

    As regards the current issue I find it difficult to see why you need all these tables.  You said in your original post 'This SQL statement converts the signal-hour fields into universal UTC military time'. However, the current Coordinated Universal Time (UTC) value can be returned by  calling the GetUTC() function from the following module.  This calls the Windows API GetSystemTime function: 

    ' basUTC

    ' returns current date/time as UTC (Coordinated Universal Time)

    ' by calling GetUTC() function 

    Option Compare Database

    Option Explicit 

    Type SYSTEMTIME

      wYear As Integer

      wMonth As Integer

      wDayOfWeek As Integer

      wDay As Integer

      wHour As Integer

      wMinute As Integer

      wSecond As Integer

      wMilliseconds As Integer

    End Type 

    Declare PtrSafe Sub GetSystemTime Lib "kernel32.dll" (lpSystemTime As SYSTEMTIME) 

    Public Function GetUTC() As Date 

        Dim utctime As SYSTEMTIME   

        GetSystemTime utctime  ' put the time and date in UTC time into utctime

        With utctime

            GetUTC = DateSerial(.wYear, .wMonth, .wDay) + TimeSerial(.wHour, .wMinute, .wSecond)

        End With   

    End Function 

    To return the UTC Time for a local date/time value the following simple little function calls the above function: 

    Public Function Local2UTC(dtmLocal As Date) As Date 

        Dim dtmDifference As Date   

        ' get difference between local date/time and UTC

        dtmDifference = Now() - GetUTC()   

        ' convert local date/time to UTC by subtracting difference from local date/time

        Local2UTC = dtmLocal - dtmDifference   

    End Function

    So, whenever you need to return the UTC date/time for any local date/time value in the database you can just call the Local2UTC function, passing the local date/time into the function.  Here is an example in the immediate window for 6:00 PM today: 

    ? Local2UTC(#2025-05-26 18:00:00#)

    26/05/2025 17:00:00 

    You can of course format the return value in whatever date/time format you want by calling the Format function.

    0 comments No comments
  2. Anonymous
    2025-05-26T00:01:40+00:00

    Thank you so much. I know I am over my head in this endeavor, but the opposite of success is not trying.

    Thank you so much. I will try to gain more knowledge and review your example.

    Helping others is a true blessing to all.

    Jerry

    0 comments No comments
  3. ScottGem 68,755 Reputation points Volunteer Moderator
    2025-05-26T00:24:01+00:00

    I have an input form to input: First name, UTC code where they live. I also have each day of the week with an individual box for time as 00:00, 01:00, through 23:00. These boxes represent the time of day where they live, and they're available to have phone or ZOOM conferences.

    I want to convert these times into universal time or world military time. Print the converted data to line up people who can meet at the same time. Like California talking to New York. In this case, we have people all over the world.

    I hope this is clear. I have limited knowledge of Access Database. I have used it in the past, and I am trying to wake up my past knowledge.

    OK, you still didn't answer where you got that code from. But you are clearly going in the wrong direction.

    You should have at least 2 tables. The first table is the info about the person, something like:

    tblPersons

    PersonID (PK Autonumber)

    FirstName

    LastName

    UTCCode

    other info about a person

    Then you need an availabili ty table:

    tblAvailability

    AvailabilityID (PK Autonumber)

    PersonID (FK)

    AvailableTime

    Next you need to understand how Access stores Date/Time values. They are stored as a double precision number where the Integer Portion is the number of days since 12/30/1899 and the decimal portion is a fraction of a day (i.e. .25 = 6AM).

    Its not clear whether you need to record availability by specific dates or Day of week and time of day. If you need specific dates then you can use the AvailableTime field as shown. If you need just daof week then have 2 fields:

    DayofWeek

    TimeofDay

    So you create a record in tblAvailability only for the times they are available. Having fields like you have is not how relational databases work.

    And there is no need for a query. What you need is a mainform/subform. The mainform is bound to tblPersons and the subform bound to tblAvailability and linked on PersonID.

    0 comments No comments
  4. Anonymous
    2025-05-26T00:55:35+00:00

    To return the UTC for other time zones than your own current one, you'd need to add a TimeZone argument to the function I gave you in my last post.  This would be of Integer  Number data type and be the local difference in hours from UTC, e.g. for Eastern Standard Time it would be -5, here in the UK it would be 0, and for Central European Time it would be 1.  It would also be necessary to add an argument for the time zone in which the function is called.  The function would now be: 

    Public Function Local2UTC(dtmLocal As Date, TimeZone As Integer, TimeZoneHere As Integer) As Date 

        Dim dtmDifference As Date   

        ' get difference between local date/time and UTC

        dtmDifference = Now() - GetUTC()   

        ' convert local date/time to UTC by subtracting difference from local date/time

        ' and adjusting for time zone

        Local2UTC = dtmLocal - dtmDifference - TimeZone / 24 + TimeZoneHere/24   

    End Function 

    For example, I'd call it in the UK for a date/time of 2025-05-25 21:00:00 (9:00 PM) in New York like this: 

    ? Local2UTC(#2025-05-25 21:00:00#,-5,0)

    26/05/2025 01:00:00

    0 comments No comments
  5. Anonymous
    2025-05-26T16:15:24+00:00

    PS: I've just noticed that some time zones don't differ from UTC by full hours, but by a multiple of 30 or 15 minutes, so the TimeZone and TimeZoneHere arguments of the Local2UTC function I gave you should be declared as Single not Integer. The values should be passed in as a decimal number e.g. 5.5 for Indian Standard Time.

    0 comments No comments