473,379 Members | 1,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to use "Insert Into" to programatically insert multiple fields into a table

CFW
I use the following flawlessly to insert a single field:

strSQL = "Insert into [_tblCasket] (Casket) Values " _
& "(" & conQuote & NewCasket & conQuote & ")"
Set db = CurrentDb

If MsgBox(NewCasket & " is not in the list. Do you want to add "
& NewCasket & _
" as a new Casket/Container in the list?", vbYesNo, _
"Add a Casket/Container") = vbYes Then
db.Execute strSQL
Response = acDataErrAdded
Else
Response = acDataErrDisplay
End If

I can't figure out the syntax to insert into multiple fields?! Can I?
TIA!
Nov 12 '05 #1
2 9857
From what I can tell you are simply not specifying multiple fields
there.
Then your values appear to be improperly formatted.

try:

strSQl = "INSERT INTO _tblCasket (field1, field2, field3 ... ) VALUES
{'" & varField1 & "' , '" & varField2 & "' , '" & varField3 & "');"

such that the concatenated string has the proper SQL format:

INSERT INTO _tblCasket (field1,field2,field3)
VALUES ('stringvalue1',#datevalue2#,numvalue3);

keeping in mind that only string values need to be quoted, dates
should be bracketed by #01/01/2003# to preserve their formatting and
numbers need no qualifiers at all.

also remember to use [] if your field names match internal keywords
such as [Date] etc.

regards,

john OBrien
Applied Computer Science

CFW <cf****@comcast.net> wrote in message news:<ts********************************@4ax.com>. ..
I use the following flawlessly to insert a single field:

strSQL = "Insert into [_tblCasket] (Casket) Values " _
& "(" & conQuote & NewCasket & conQuote & ")"
Set db = CurrentDb

If MsgBox(NewCasket & " is not in the list. Do you want to add "
& NewCasket & _
" as a new Casket/Container in the list?", vbYesNo, _
"Add a Casket/Container") = vbYes Then
db.Execute strSQL
Response = acDataErrAdded
Else
Response = acDataErrDisplay
End If

I can't figure out the syntax to insert into multiple fields?! Can I?
TIA!

Nov 12 '05 #2
you mean you couldn't copy anything from an Insert query? Or the help
file? The help file is your friend!

INSERT INTO table (field1, field2, field3...) VALUES
(value1,value2,value3)
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
2
by: EricRobineau | last post by:
hello I have a DB with many inter-related tables (MySQL) My main table called "content" has almost only foreign keys (integers) some have a 3 level relation (ex: content->city->region->country) ...
5
by: Chad Richardson | last post by:
Is there a way in SQL Server 2000 to extract data from a table, such that the result is a text file in the format of "Insert Into..." statements, i.e. if the table has 5 rows, the result would be 5...
6
by: Rich | last post by:
Hello, I have to create a table in an Access mdb (remotely) on the fly. Create Table tbl1(fld1 Integer, fld2 varchar(10), fld3...) Then I have to insert data: Insert Into tbl1 Values(" &...
8
by: Ian Davies | last post by:
Hello I have the following sql string to run as a command in my VB6 project to update mysql table strSQL = "LOAD DATA INFILE " & ImportFile & " INTO TABLE tPupils FIELDS TERMINATED BY ','...
0
by: MarceloLinero | last post by:
Hi, i`m problem whith it !! help me ! No found way for insert in table directy in database sql express and no undertand why ! steps in general: 1. create coneccion ready 2. declarate a...
5
by: djsdaddy | last post by:
Good Day All, I have some EEO data in an old dBase4 database that I have converted to an Access table. Since dBase was not a relational database, I didn't create any key fields. I linked all of the...
3
by: Twanne | last post by:
Hi, I've got a table called Aerosol and a table called LinkTabel. Now I do an update to a table from an excell sheet, this table is called ExportAerosol. So far so good, the import works...
0
by: John | last post by:
Hi I have written a function to split a string into sub strings of a given fixed max length. This is useful for example in breaking a long message into multiple strings of up to 160 characters...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.