Results 1 to 4 of 4
  1. #1
    willkr is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2023
    Posts
    110

    Syntax question


    I'm going through someone else's code. On SELECT statements I see some fields referenced as "tblName.fieldName" and others are referenced as "tblName.[fieldName]" What's the difference?

  2. #2
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    The square brackets in your example serve no purpose. However, if fieldName was called "field name", then you'd totally need the square brackets, because look what happens:
    tblName.field name
    tblName.[field name]

    In the first, Access thinks tblName has a method field and name is an argument of that method.
    In the second, the reference is made correctly. That's why you should call your things without special characters, like space, that way you avoid having to type the annoying square brackets. By the way, Access adds them automatically for you most of the times.
    Please click on the ⭐ below if this post helped you.


  3. #3
    willkr is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2023
    Posts
    110
    Thank you. That was very helpful!

  4. #4
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    Happy to help
    Please click on the ⭐ below if this post helped you.


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

Similar Threads

  1. Combo Box - DoCmd syntax question
    By fountain27 in forum Forms
    Replies: 5
    Last Post: 04-23-2019, 07:08 PM
  2. Criteria syntax question
    By Radtastic10 in forum Queries
    Replies: 17
    Last Post: 06-29-2016, 02:46 PM
  3. Simple code syntax question
    By mseeker22 in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 03:55 AM
  4. ORDER BY ... If (SQL syntax question)
    By Remster in forum Forms
    Replies: 9
    Last Post: 05-18-2011, 06:54 AM
  5. simple syntax question
    By markjkubicki in forum Programming
    Replies: 6
    Last Post: 09-14-2010, 04:13 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