mem81 0 Light Poster

Hello,

I spent hours wondering why this statement doesn`t work.
I would like to insert record in a table if it doesn`t exist already.If record exists then a message will come out saying record exists.
The values for the record to be inserted are current selection in combos on a form .

Here is my statement:

INSERT INTO Table ( [Field1], [Field2], [Field3], [Filed4], [Filed5],[Filed6], [Filed7])
SELECT [Forms].[frmName].[combo7] AS Expr1, [Forms].[frmName].[combo9] AS Expr2, [Forms].[frmName].[combo49] AS Expr3, [Forms].[frmName].[combo15] AS Expr4, [Forms].[frmName].[text47] AS Expr5, [Forms].[frmName].[cboReportingPeriod] AS Expr6, [Forms].[frmname].[text21] AS Expr7
FROM table1
GROUP BY [Forms].[frmName].[combo7], [Forms].[frmName].[combo9], [Forms].[frmName].[combo49], [Forms].[frmName].[combo15]
if   not exists
(Select Field1, Field2, Field3, Filed4, Field5, Field6, Field7
from Table
where Field1=[Forms].[frmName].[combo7] and Field2=[Forms].[frmName].[combo9] and Field3=[Forms].[frmName].[combo9] and Filed4=[Forms].[frmName].[cboReportingPeriod])

I get an error in the insert into statent when trying to run it in access.
Please help, what am I doing wrong
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.