Link to home
Start Free TrialLog in
Avatar of andyb7901
andyb7901

asked on

Simple Insert Query

Hi,
Can someone tell me why my stupid database wont insert a simple query;

INSERT INTO [Gap Analysis - 02/10/2007] (1)
VALUES ("abc");

All fields are strings, a the 1 is a column heading? I get an error;

Type Conversion Error. How am I supposed to be putting in text feidls then? I have tried, '  , [ ], leaving it blank. This is the simplest query but it will not let me execute it?
Avatar of Ashish Patel
Ashish Patel
Flag of India image

Try double quote around 1
ASKER CERTIFIED SOLUTION
Avatar of j-w-thomas
j-w-thomas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j-w-thomas
j-w-thomas

If you insert numbers into a number field, no quotes at all are needed, if you insert dates into a date field it must be enclosed in # sign.

INSERT INTO TABLENAME (STRINGFIELD, DATEFIELD, NUMBERFIELD) VALUES ('abc', #12/25/2006#, 125)

MS Access is very specific...

John
Avatar of andyb7901

ASKER

I have done the following as well;

INSERT INTO [Gap Analysis] ( [And] )
VALUES ("Help");

I get to the "You are about to Append 1 Row" status screen. If I continue oast this I get the same error message again!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have figured it out. The required field was set to Yes on all fields. I am creating a table on the fly through VBA. Can anyone tell me how I would create the table with the requireed field set to NO on all records. My current code is;

With tbl1
            .Name = GapTitle & " - " & Date
            For j = 1 To NoOfControls
                FieldText = Me("Text" & j)
                .Columns.Append FieldText, adVarWChar, 30
            Next
        End With
sorry can't help with that...