Brackets and Exclamation Points (1 Viewer)

bnw

Registered User.
Local time
Today, 14:22
Joined
Sep 19, 2006
Messages
26
I have a question about the below query. I never use brackets and exclamation point to distinguish my table name and field names. Why are the brackets and exclamation point used in this query? :(This query is from a sample Access Database. I look forward to hearing from you soon.




SELECT DISTINCTROW Registration.EventID, Registration.AttendeeID, [Attendees]![LastName]+", "+[Attendees]![FirstName] AS [Attendee Name], Attendees.Company, Registration.RegistrationFee, qrySumOfPayments.TotalPayments
FROM Attendees INNER JOIN (Registration LEFT JOIN qrySumOfPayments ON Registration.RegistrationID=qrySumOfPayments.RegistrationID) ON Attendees.AttendeeID=Registration.[AttendeeID]
ORDER BY [Attendees]![LastName]+","+[Attendees]![FirstName];
 

DCrake

Remembered
Local time
Today, 22:22
Joined
Jun 8, 2005
Messages
8,632
Square brackets are used around field names if there are spaces in the name of the field. also if you have field names in two or mare tables in the query that are the same then you need to distinguish which table the field is looking at thus the [Table One]![Field One] syntax applies. The ! is telling access to look at this field in this table.

Short and sweet answer. A more defnitive answer can be obtained via Access help.
 

bnw

Registered User.
Local time
Today, 14:22
Joined
Sep 19, 2006
Messages
26
Square brackets are used around field names if there are spaces in the name of the field. also if you have field names in two or mare tables in the query that are the same then you need to distinguish which table the field is looking at thus the [Table One]![Field One] syntax applies. The ! is telling access to look at this field in this table.

Short and sweet answer. A more defnitive answer can be obtained via Access help.

Thanks DCrake

I knew about using the bracket when a field name(s) have spaces and thanks for the clarification on using the ! point as well as the brackets that distinguish a field name and table.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:22
Joined
Feb 19, 2002
Messages
43,484
Brackets don't distinguish a field from a table. I don't see any problems with the table or column names that would require brackets. The query looks like it was updated by someone who preferred that syntax. If you change the references to Attendees.FirstName and Attendees.LastName, they should work fine. You need to leave the square brackets for the [Attendee Name] field since it contains a "not allowed" special character - the space.
 

Users who are viewing this thread

Top Bottom