473,727 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RecordSet and SQL Insert Query Trouble

After having googles I've knocked together ther following code. What I
am trying to do is select all items in one table and move through them
adding them into other tables (splitting them and putting different
parts in different table linked together with relationships).

THe bits that I can't figure out are:
1) how to get info from the recordset (i.e. select info from that to
put into the other tables using insertSQL)

2) how to solve the Error: 424 I get on Line (Set WorkRS1 =
WorkBase.Ope... ..)

I'm more of a php man so the code to me would be:

while($Var = mysql_fetch_arr ay($record_set) ) {
$sql = "INSERT INTO table ([Field]) VALUE (" &
$Var["FieldNameFromR ecordSet"] & ")"
}

But I'm taking my first leaps into access.

Private Sub Command1_Click( )
Dim strSQL As String
Dim insertSQL As String
strSQL = "SELECT ContactFirst,Co ntactSurname FROM tbl_Contacts ORDER BY
ContactSurname"

Set WorkRS1 = WorkBase.OpenRe cordset(strSQL)

Do Until WorkRS1.EOF

' INSERT INTO CLIENTS TABLE
insertSQL = "INSERT INTO tbl_Clients
([ClientName],[ClientAddress1],[ClientAddress2],[ClientAddress3],[ClientTown],[ClientCounty],[ClientPostcode])
VALUES ('','','','','' ,'','');"

'INSERT INTO CONTACTS TABLE
WorkRS1.MoveNex t
Loop

WorkRS1.Close
WorkBase.Close

End Sub

Jun 29 '06 #1
1 1966

Sockpuppet wrote:
After having googles I've knocked together ther following code. What I
am trying to do is select all items in one table and move through them
adding them into other tables (splitting them and putting different
parts in different table linked together with relationships).

THe bits that I can't figure out are:
1) how to get info from the recordset (i.e. select info from that to
put into the other tables using insertSQL)

2) how to solve the Error: 424 I get on Line (Set WorkRS1 =
WorkBase.Ope... ..)


Why would you want to use code at all for this? Well, other than
executing a series of SQL statements?

I'd just use a series of append queries and that should do it. No
recordsets required.

Something along the lines of

Sub SplitData()
dbEngine(0)(0). Execute "INSERT INTO...",dbFail OnError
End Sub

Looksto me like you're making things a lot harder than they need to be.

Jun 29 '06 #2

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

Similar topics

2
1906
by: avinash | last post by:
hello myself avinash i am developing on application having vb 6 as front end and sql server 7 as back end. when i use insert query to insert data in table then the date value of that query is going as 01/01/1900 my query is as follows StrSql = "Insert Into SalesVoucher(TransactionID,VoucherNo,VoucherDate,DebitTo,CreditTo,TotalAmt,Discount,ModAmt,ModWt,Other,Othertype,TaxPerc,TaxAmt,NetAmt,Advance,Narration,Haste)" StrSql = StrSql & "...
8
6292
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with one-to-one relationship but on this occasion I must keep username/password details within a seperate table. Here's the basic specs and database schema: -------------------------------------------
5
15415
by: Annie | last post by:
hello guys, I have little experience working with C# and MS Access ... I am having an insert query with one datetime field and a boolean and couple of text and number fields as below: "Insert into order (OrderClientID, OrderDate, OrderOfferID, OrderIsSpecial, OrderShipment) Values (6, # 16/09/2005 2:38:51 PM # , 1 , 0 , 'hello there it is test')"
0
1288
by: clickon | last post by:
I want to use an INSERT Query as the value for the UpdateCommand property of an SQL datasource, anyone know if this will actually work ? The reason i want to do it is bacause i am taking values from tablea and binding them to controls, whose values i want to insert into tableb. I am using a detailsview control to do the databinding. If the detailsview is in edit mode then it displays the data from table A in the bound testbox controls...
3
2448
by: tyngtyng | last post by:
hi... i'm new to the php and now i'm getting an error to insert my data inside the form..and also undefined index in latest_updated...... Now,i'm having trouble catching what i'm doing wrong....Here's my code to the query entry... <?php include 'config.php'; $pili_id=$_POST; $branch=$_POST;
1
6209
by: abhi81 | last post by:
Hello All, I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp. Insert and Update trigger work fine when i have only one of them defined. However when I have all the 3 triggers in place and when i try to fire a insert query on the statement. It triggers both insert and update trigger at the same time and...
1
2761
by: Luqman | last post by:
I have created a Insert Query in Sql Data Source using Oracle Database, with the parameters, and its connected with DetailView Control. When I try to Insert through DetailView Control, Illegal Variable Name/Number Error occurs. Is there any way I can trace or display on screen, what exactly the query is being passed to the Oracle with the Values. For example: If my Sql datasource has following query.
0
2288
by: magnolia | last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time which means i hav 2 record for every insert operation. any help appreciated. thank u herez teh code i tried. ALTER TRIGGER trg_ContactAddress_Audit ON Address FOR DELETE, INSERT, UPDATE AS
1
2062
by: Marco van der M | last post by:
Hello everyone, I am trying to make an insert query that inserts information using form values and a query that gets the id from the name of a field in the form. I got a form that shows object name, date completed and department completed. I am trying to do the following: INSERT INTO DB (Person_id, Object_id, Date_completed, Department_completed) Values (Forms!Form1!Person_id, Querydata, Forms!Form2!Date_completed,...
0
8891
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
8752
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
9260
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...
1
9185
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6703
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
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3228
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
3
2158
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.