I’ve been given an MS-Access application to maintain and being more acquainted with Oracle as dbms I bump into issues now and then..
Today it looks like MS-Access has problems when a hyphen is used for a column name…
The following insert statement was coupled to the NotInList event to add an extra entry to a listbox.
INSERT INTO tblProductInfo ( ProductInfo-Product )
“SELECT “”” & NewData & “”” AS ProductInfo-Product;”
But it’s not working (anymore? first time the issue is reported, not sure if the original developer tested it out).
I’ve tested it out with a single-record append query and it looks like the hyphen is the culprit and I just cannot find a way to escape that..
INSERT INTO tblProductInfo ( ProductInfo-Product ) VALUES (“myData”)
The error given is “Syntax error in INSERT INTO statement”
There does not seem any other way to specify the MS-Access fieldname, is it? (square brackets are only used for SELECT statements,
So… I’m calling for the wisdom of the Stackoverflow gods and am hoping someone knows how to solve this…
Thanks in advance !!
You need square brackets on that:
Or better yet, avoid odd characters and spaces in field and table names.
Square brackets are used in any sql statement where the field or table name is problematical:
You can even use them with DDL: