• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 906
  • Last Modified:

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?
0
andyb7901
Asked:
andyb7901
3 Solutions
 
Ashish PatelCommented:
Try double quote around 1
0
 
j-w-thomasCommented:
INSERT INTO TABLENAME (1) VALUES ('abc')

Also, is the column name actually *1* ? If it is, I would suggest that MS Access will not like that at all.

You need to use single quotes aound all string values even if the are numbers.

But again, MS Access will not like a number for a column name even though it accepts it when you create it.

John
0
 
j-w-thomasCommented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
andyb7901Author Commented:
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!
0
 
Jinesh KamdarCommented:
What version of Access are you using? I tried it on MS Access 2003 and it worked.
0
 
Patrick MatthewsCommented:
INSERT INTO [Gap Analysis - 02/10/2007] ([1])
VALUES ("abc");
0
 
andyb7901Author Commented:
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
0
 
j-w-thomasCommented:
sorry can't help with that...
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now