Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access / SQL : error in insert query statement

Tags:

sql

vba

ms-access

I am using MS Access 1997 version (.mdb file). On a daily basis, I need to insert values manually. In that file, there's a column Logical (Boolean data type). I am automate this template using SQL query instead of direct entry.

Below is my insert query:

Insert Into Data_CustomerTransmit_Tbl (Logical) 
Values (" & Logicalnme & ")

Values:

Logicalnme - True

When I run this query in VBA in Excel, I get this error message

Syntax Error in Insert into Statement

Kindly confirm shall I use "Logical" as column name or this is the reserved keyword?

Thanks in advance.

like image 703
user2095503 Avatar asked Sep 02 '16 12:09

user2095503


People also ask

How do you insert data into an Access database using query?

You can also use INSERT INTO to append a set of records from another table or query by using the SELECT … FROM clause as shown above in the multiple-record append query syntax. In this case, the SELECT clause specifies the fields to append to the specified target table.

What is the correct syntax for insert into?

There are two basic syntax of INSERT INTO statement is as follows: INSERT INTO TABLE_NAME (column1, column2, column3,... columnN)] VALUES (value1, value2, value3,... valueN);

What is syntax error in MS Access?

Syntax error (missing operator) in query expression 'TableName. FieldName'. Note The TableName placeholder represents the name of the table that you are querying. The FieldName placeholder represents the name of the field name that you are querying. Note This issue may also occur for objects other than tables.

Why does Access query have #error?

The #Error error value means that Access cannot evaluate an expression. For example, you may have supplied incorrect or too few arguments for an aggregate (totals) function, you may have used a parameter query as the domain for an aggregate function, or you may have made a circular reference in the expression.


1 Answers

There isn't a problem with your field name, you just need to enclose your INSERT column name in square brackets. You also need to choose a valid value in the VALUES clause:

INSERT INTO Data_CustomerTransmit_Tbl ( [Logical] )
VALUES (TRUE);

If you want to be prompted for the value to insert, you can use a parameter:

PARAMETERS [Please enter a Boolean value] YesNo;
INSERT INTO Data_CustomerTransmit_Tbl ( [Logical] )
VALUES ([Please enter a Boolean value]);
like image 148
ThunderFrame Avatar answered Oct 12 '22 21:10

ThunderFrame