Mr. Finn
Mr. Finn

Reputation: 99

Runtime Error 3134 Unable to Identify the issue

I am getting a Runtime Error 3134 on the following code based from an onclick event

   strEnt = "INSERT INTO EntList (EntityID, BusinessUnit, EntityName, Position, Location, Client, Dept, DistKey, Salary, Currency, SQ&A, BillRate, Util%, MeritDate, MeritRate) " & _
         "VALUES ('" & Me.EntityID & "', '" & Me.BusinessUnit & "', '" & Me.EntityName & "', '" & Me.Position & "', '" & Me.Location & "', '" & Me.Client & "', '" & Me.Dept & "', '" & Me.DistKey & "', '" & Me.Salary & "', '" & Me.Currency & "', '" & Me.SG_A & "', '" & Me.BillRate & "', '" & Me.Util_ & "', '" & Me.MeritDate & "', '" & Me.Merit_ & "');"
Debug.Print strEnt
CurrentDb.Execute strEnt

The debug.print command outputs the following code to the immediate window

    INSERT INTO EntList (EntityID, BusinessUnit, EntityName, Position, Location, Client, Dept, DistKey, Salary, Currency, SQ&A, BillRate, Util%, MeritDate, MeritRate) VALUES ('Test10', 'CSS Overhead', 'Walter Tester', 'AutoentryTest', '01002 TELETECH SERVICE CORPORATION', '0001 US LABOR ARB CLIENT', '001 CORPORATE/COMPANY ALLOCATIONS', 'DAE', '250000', 'USD', '0', '300', '1', '', '');

Everything Looks like it should work as far as I can tell, can someone help me see what I am missing?

Upvotes: 1

Views: 58

Answers (1)

RBarryYoung
RBarryYoung

Reputation: 56725

The Access SQL that you are trying to execute:

INSERT INTO EntList (EntityID, BusinessUnit, EntityName, Position, 
                     Location, Client, Dept, DistKey, Salary, Currency, 
                     SQ&A, BillRate, Util%, MeritDate, MeritRate) 
            VALUES ('Test10', 'CSS Overhead', 'Walter Tester', 'AutoentryTest', 
                    '01002 TELETECH SERVICE CORPORATION', '0001 US LABOR ARB CLIENT', 
                    '001 CORPORATE/COMPANY ALLOCATIONS', 'DAE', '250000', 'USD', '0', 
                    '300', '1', '', '');

contains some invalid column name references. SQ&A is definitely not a valid reference, and both Util% and Currency may also be invalid. The first two are invalid because they contain characters that are not valid for an unquoted name reference. And Currency may be invalid because it may be a reserved word (I am not sure about this one).

The solution to this to just quote them with brackets ([..]):

INSERT INTO EntList (EntityID, BusinessUnit, EntityName, Position, 
                     Location, Client, Dept, DistKey, Salary, [Currency], 
                     [SQ&A], BillRate, [Util%], MeritDate, MeritRate) 
            VALUES ('Test10', 'CSS Overhead', 'Walter Tester', 'AutoentryTest', 
                    '01002 TELETECH SERVICE CORPORATION', '0001 US LABOR ARB CLIENT', 
                    '001 CORPORATE/COMPANY ALLOCATIONS', 'DAE', '250000', 'USD', '0', 
                    '300', '1', '', '');

Upvotes: 1

Related Questions