access

O

Ofer Cohen

There might be some more reasons for using square brackets, but there are some

1. When you want to refer to a field or table that contain more then one
word, in code or in a query

RecordSourceName![Field Name] ' as a field in a table
Me.[Field Name] ' as a form object

Select [Table Name].[Field Name] From [Table Name]

*********************
2. When you want to use a parameter prompt in a query

Select * From TableName Where FieldName = [Please enter a value]

the user will be prompt with the message [Please enter a value]
*********************
3. If a field name is a key word in Access

Select [Date] From TableNAme

Where Date is also a function used to return the current date

**********************
It's recomnded not to use key words as fields names, and to connect the
words like
First_Name Or FirstName

Instead of
First Name
 
B

Brendan Reynolds

LifeDream said:
what dose these mean in access []?


The square brackets are used for different purposes depending on the
context. In SQL statements they are used to demark field names that contain
spaces or other non-alphanumeric characters. For example if you have a
column named 'Customer ID' you'll need square brackets around it in a SQL
statement like so ...

SELECT [Customer ID] FROM Customers

They're also used with the 'LIKE' operator to indicate that a character
which is usually used as a wild card character is to be treated as a literal
character instead. For example the asterisk is usually a wildcard character
representing one or more characters, so to select records that contain the
asterisk in a specified column you might use an expression such as ...

SELECT Customers.*
FROM Customers
WHERE (((Customers.Company) Like "*[*]*"));

Here the asterisk within the square brackets will be interpreted as a
literal search character, while the two asterisks outside the square
brackets will be interpreted as wildcard characters.
 
Top