Results 1 to 7 of 7
  1. #1
    KeithJAW2 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2025
    Posts
    4

    Query name is suddenly invalid.


    I'm using a database that has evolved over a number of years, and was working okay just days ago.
    I decided to make a small edit to a report, but when trying to assign a field to a variable, ran across the following error.
    "'Booking Query' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long"
    I did a workaround, but when I tried an initial check, the same error came up on the screen, as soon as I clicked on the link to the report.
    I found that a different report which used a modified version "Booking Query 2" worked okay, so decided to assign that query to the first report as well.
    However, when running the program, I now get "'Booking Query 2' is not a valid name" for both reports.

    I thought maybe that MS had changed Access to disallow spaces in query names, so took the spaces out of both query names.
    Same result.

    It feels like something has become corrupted, but only as a result of my minor tweak, which is very strange.

    Any suggestions?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Would have to examine database. If you want to provide, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    suggest show your sql - impossible to advise otherwise. Not good practice, but you can still have spaces in table/query names providing you surround with square brackets.

  4. #4
    KeithJAW2 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2025
    Posts
    4
    Code:
    SELECT [FirstName]+" "+[LastName] AS Expr4, Reservations.*, [Names and addresses].*, [Total Price]-[Deposit Amount] AS [Balance Amount], Reservations.[Period From], [Reservations.Period From]-42 AS DateDue, [Balance Amount]-[Balance] AS Outstanding, Reservations.[Pay on Arrival], IIf([Pay on Arrival]=True,[Outstanding]) AS Expr1, Reservations.[Agent Costs], [Reservations.Period To]-[Reservations.Period From] AS [no of nights], [Reservations.Period From]-28 AS DateDueHL, Reservations.[Payment Type], Reservations.[Deposit Paid], Reservations.[Deposit Paid Date], Reservations.[Balance Paid], Reservations.[Balance Paid Date], [Total Price]-[Deposit Paid]-[Balance Paid] AS Expr5, Reservations.Route, Reservations.[Email Requested], Reservations.[Booking Form Received], Reservations.Pet, [Total Price]-[Agent Costs] AS Expr2, [Round((Reservations.No of Nights)/7+.5)] AS [No of weeks]FROM [Names and addresses] INNER JOIN Reservations ON [Names and addresses].[Mailing ListID] = Reservations.CustomerID
    WHERE (((Reservations.[Period From])>=DateSerial([Forms]![Menu]![Year],1,1) And (Reservations.[Period From])<=DateSerial([Forms]![Menu]![Year],12,31)))
    ORDER BY Reservations.[Period From];

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The preferred character for concatenation is &: [FirstName] & " " & [LastName]

    Use + for concatenation if either field could possibly be Null and you want to prevent orphan spaces or commas. This is because + is also arithmetic in nature. Adding anything to Null returns Null. Whereas using & to concatenate text with Null will return text.
    However, using two + signs as you have would return nothing if either field is Null. Consider [FirstName] & " " + [LastName]. The + operation will take precedence to combine " " with [LastName] and return Null if [LastName] is Null then & will combine [FirstName] to whatever is returned by + operation. Unfortunately, if [FirstName] is Null then a not Null [LastName] will return with a leading space. So this can get rather complicated.

    Unfortunately, that does not explain cause of your issue as query should still run.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    You are returning reservations.* and what looks like many of the reservations fields again leading to duplicate columns - not a particularly good way of doing things.

    i also don’t see any reference to anything ‘booking query’ which makes me think you have in the query properties a filter or sort which references it

  7. #7
    KeithJAW2 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2025
    Posts
    4
    Thanks for your replies.

    I got round the problem by using a back-up copy and appending the data from the up-to-date copy. But I'm going to try and clean up my act by taking note of your comments above.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 11-27-2023, 02:27 PM
  2. ODBC sql server driver invalid object name "query name"
    By masoud_sedighy in forum SQL Server
    Replies: 4
    Last Post: 10-06-2017, 10:12 AM
  3. Replies: 2
    Last Post: 01-20-2016, 12:41 PM
  4. Replies: 5
    Last Post: 07-22-2014, 06:58 AM
  5. Replies: 7
    Last Post: 08-28-2011, 02:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums