Developers Archive for the 'ms access database' Category

Microsoft JET Database Engine (0×80040e14) Syntax error in FROM clause

Microsoft JET Database Engine (0×80040e14) Syntax error in FROM clause Wednesday, January 24th, 2007

Syntax error in FROM clause
This commonly occurs when you have a table name that is a reserved word or your table name contains a space

(eg “table 1″).

Certain words (like table, field, date, select, password, level etc) are reserved by either ADO, OLEDB or by Access

for use as commands or system objects.

You should never use these words as names for tables or fields nor should you have spaces in your tablenames. It

is recommended that you rename your offending tables/fields and adjust your SQL statement accordingly.

If this is not possible you should enclose your offending table names with [ ] marks, eg

SELECT field1
FROM [table]

Syntax error in INSERT INTO statement.
This commonly occurs when your field name is a reserved word (see scenario 1 above). Adjust your field names and

SQL statement accordingly and you should avoid the problem.

If you can’t adjust your fieldnames you can use [ ] marks to delimit the field names, eg

INSERT INTO table1
([field], [password])
VALUES (’value1′, ‘value2′)

Microsoft JET Database Engine (0×80040e14) Syntax Error (Missing Operator) in query expression

Microsoft JET Database Engine (0×80040e14) Syntax Error (Missing Operator)  in query expression Wednesday, January 24th, 2007

This is commonly caused when some value that you are trying to SELECT/UPDATE etc contains a single quote mark. The error that you receive looks like:

Microsoft JET Database Engine (0×80040e14)
Syntax error (missing operator) in query expression ‘Name = ‘Carolyn O’Tooley'’.
Because of the presence of the ‘ in the name Carolyn O’Tooley the database engine thinks that you are constructing a WHERE clause like:

WHERE name = ‘Carolyn O’
and doesn’t know what to do with the rest of the name (Tooley). To solve this problem you need to use the Replace() function and replace all single quotes with two single quotes.

How to make a change to dates by using functions and operators in Microsoft Access

How to make a change to dates by using functions and operators in Microsoft Access Thursday, December 28th, 2006

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
Date() function

The Date() function returns the current date in the short-date format.

Eg: 12/28/2006

Now() function

The Now() function returns the current date with the time.

Eg: 12/28/2006 04:46:50 PM

Format() function

use the Format() function with date values to specify the date format that you want to use for the date.

Eg: Format(Now() , “mmmm dd yyyy”)

The above example returns the current date in the format

December 28 2006

Day() function, WeekDay() function, Month() function, and Year() function

Eg: select Day(BirthDate) , WeekDay(BirthDate) , Month(BirthDate) , Year(BirthDate) from tblUser

The above query returns the day of birth, week of birth, month of birth and year of birth for each user from the table tblUsers. Note that the WeekDay() function returns a numeric value that indicates the day of the week.

DatePart() function

The DatePart() function can be used to extract the part of the specified date, such as the day, the month, or the year.

Eg: select DatePart(”yyyy”, BirthDate) from tblUsers

The above query returns the year component of the specified date.

DateDiff() function

The DateDiff() function returns the difference or the time lag between the two specified date values (in terms of the day, the month, the year, or the time units, such as hours, minutes, and seconds).

Eg: select DateDiff(”yyyy”, BirthDate, Date()) as Age from tblUsers

The above query returns the difference of years between the birthdate of the user and the current date.

DateAdd() function

The DateAdd() function increments a date by a specified number of time units, such as a day, a month, or a year and then returns the resultant value.
Eg: DateAdd(”yyyy”, 10, BirthDate)

The above example will add 10 years to the birthdate
DateValue() function

The DateValue() function verifies whether the input string is a valid date. If the input string is recognized as a valid date, the date is returned in short-date format. If the input string is not recognized as a valid date, the statement “Data type mismatch in criteria expression” is returned. The DateValue() function recognizes a variety of date formats, such as mm dd yyyy, dd mm yyyy, dd mmm yyyy, and dd mmm yyyy hh:mm:ss long date format.

Eg: SELECT DateValue(”28 Dec 2006″) AS ValidDate; 

DateSerial() function

The DateSerial() function returns the date value for the specified input parameters of year, month, and day. The input parameters can be expressions that involve arithmetical operations. The DateSerial() function evaluates the expressions in the input parameters before it returns the resultant date value.
Eg: SELECT DateSerial( 2006,  05, 1-1);

This example query returns the last day in the month of April for the year 2006. The last input parameter for the day with the value of 1 is decremented by 1. The result is that the month parameter is evaluated to 4.

WeekdayName() function

Eg: SELECT WeekdayName(1, False, 1) AS FirstWeekDayName;

The WeekdayName() function returns a string that indicates the day of the week, as specified in the first parameter. The day of the week string that is returned depends on the third parameter. This parameter sets the first day of the week. The second parameter is set to False to specify that the weekday name must not be abbreviated.
MonthName() function

SELECT MonthName(1)

The MonthName() function returns a string that indicates the month name for the specified month number from 1 through 12. The input parameter can also be an expression, as in the following query:

Eg: SELECT MonthName( DatePart(”m”, Date()) );

This query returns the name of the current month.

Using Comparison Operators With Date Values

You can use the following comparison operators to compare date values in expressions and in queries:

<(less than)

>(greater than)

<=(less than or equal to)

>=(greater than or equal to)

<>(not equal)

SELECT * FROM tblUsers
WHERE BirthDate >= DateValue(” 10/01/1963″)
AND BirthDate <= DateValue(”12/31/1973″);

This query uses the >= comparison operator and the <= comparison operator to verify whether the birth date of the user falls in the range of the two specified dates.

 

 

 

 

 


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.