473,659 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(NewCaske t & " 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 = acDataErrDispla y
End If

I can't figure out the syntax to insert into multiple fields?! Can I?
TIA!
Nov 12 '05 #1
2 9878
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#,n umvalue3);

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(NewCaske t & " 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 = acDataErrDispla y
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
5633
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 first name, last name, email, etc. The data are then sent to a PHP script (reg.php). The data are then inserted into a table (reg) in MS SQL server. I have declared the variables like this: if (!(isset($_POST))) { $FirstName = "" ;
2
4701
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) I would like admins to be able to insert new records including all the "content" fields (in 1 page form) But how can I make an insert form that would display the related tables as list menus instead of a textfield with a number? (ex: select
5
3094
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 lines of : insert into Table (, , .... VALUES a,b,c) insert into Table (, , .... VALUES d, e, f) insert into Table (, , .... VALUES g, h, i) insert into Table (, , .... VALUES j, k, l) insert into Table (, , .... VALUES m, n, o)
6
1937
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(" & val1 & ", '" & val2 & "',...")"
8
2574
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 ',' ENCLOSED BY ' " ' LINES TERMINATED BY '\n';" Problem is the double quote at position ......" ' LINES...... causes the command to fail thinking the double quote is ending the SQL but
0
2416
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 sqlcomand (insert into "table" values "values") etc 3. see database and no do nothing !
5
4584
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 tables together on Employees' SSN; therefore, in order to use this data with the current Access database, I need to create a relationship between the old dBase4 EEO data and the Access employee data. The Access employee data was also an old dBase...
3
1694
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 perfect. Now when I want to transfer the data from the ExportAerosol table to the Aerosol table I have to make a unique key. I do this by adding a string to another key. Now there is no problem when I update the Aerosol table. It adds the values I...
0
1626
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 to be sent as individual SMS. I am posting the function here in case its useful for someone. Regards
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8339
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2757
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.