473,327 Members | 2,007 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,327 software developers and data experts.

Help with copying values from a table into another table

hello , i just wanted to ask if there's anyone who could help me do the following thing : i have an empty temporary table, this table will have a row filled with data grabbed by a querry at this point this point another query filters this data (it was the only way to do this as i know) and inserts it into an empty table called MOVIMENTI. until here all works just fine. after i finished this part i grab the data from MOVIMENTI and other 2 linked tables called T001 and T002 and some of the values are being copied to the final table called FMX (this one is linked too to the database) while some other values are being elaborated (for example transformation of date format from DD/MM/YYYY to YYYYMMDD and so on) so far i figured out how to do all this work and i think is ok there's a problem still : my code until now worked but after i added the docmd run query things i think it stopped working , i paste the code here maybe there's some one who could give me some hints thank's alot ! , i forgot to mention that the do loop is executed until it arrives at the end of T002 ,which is 4 rows long the T001 is only 1 row so it should copy the same data for the duration of the cycle (4 times).

Dim db As DAO.Database



'''''''''''''''''sql shits''''''''''''''''''''''''''''''''
DoCmd.RunMacro "Macro2" 'azzera le tabelle MOVIMENTI E SMWFMX

DoCmd.OpenQuery "Q_salva_mov"
DoCmd.Close acQuery, "Q_salva_mov", acSaveYes

DoCmd.OpenQuery "Q_integra_sim_si"
DoCmd.Close acQuery, "Q_integra_sim_si", acSaveYes

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

Dim var_string As String, contatore As Integer, variabile
Dim var_double As Double


'dopo aver dichiarato le varie variabili (array contatori e cosivia
'dichiariamo anche le variabili per le tabelle campi record ecc....

'queste sono per la Db in cui andremmo a leggere



Dim rst_T001 As DAO.Recordset, rst_T002_FMX As DAO.Recordset
Dim rst_T002_FIX As DAO.Recordset, rst_movimenti As DAO.Recordset

'queste sono per il file su cui scriveremo


Dim rst_SMWFMX As DAO.Recordset


'impostiamo l'oggetto DB

Set db = CurrentDb()

'apri la tabella T001_SYS per leggere qualche cosa :P, in seguito apri anche SMWFMX per iniziare a scriverci sopra


Set rst_T001 = db.OpenRecordset("T001_SYS")
Set rst_T002_FMX = db.OpenRecordset("T002_FMX")
Set rst_T002_FIX = db.OpenRecordset("T002_FIX")
Set rst_movimenti = db.OpenRecordset("MOVIMENTI", , dbAppendOnly)
Set rst_SMWFMX = db.OpenRecordset("SMWFMX")


'vai a capo in tutte le tabelle

rst_T001.MoveFirst
rst_T002_FMX.MoveFirst
rst_SMWFMX.FindFirst ("smwfmx")
'cicla e scrivi dati su FMX

Do

rst_SMWFMX.AddNew
rst_SMWFMX![SMWFMX-UTENTE] = rst_T001![UTENTE]
'rst_SMWFMX.Update

rst_SMWFMX.AddNew
rst_SMWFMX![SMWFMX-REGISTRO] = rst_T001![REGISTRO]
rst_SMWFMX.Update

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''
variabile = Right(Date, 2)
variabile = variabile & variabile

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-ESERCIZIO] = variabile
rst_SMWFMX.Update
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-NUM-PROT] = rst_T001![NUM-PROT] + 1
rst_SMWFMX.Update
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-SEQUENZ] = rst_T002_FMX![SEQUENZ]
rst_SMWFMX.Update

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-TIPO] = rst_T002_FMX![TIPO]
rst_SMWFMX.Update

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-CONTO] = rst_T002_FMX![CONTO]
rst_SMWFMX.Update
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
variabile = Date
variabile = Right(variabile, 4) & Mid(variabile, 4, 2) & Left(variabile, 2)

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-Data-reg-8] = variabile
rst_SMWFMX.Update
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-iva-reg-8] = variabile
rst_SMWFMX.Update
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-Data-doc-8] = variabile
rst_SMWFMX.Update

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''
variabile = rst_T002_FMX![d-a]
If variabile = 68 Or 100 Then
variabile = "+"
Else
variabile = "-"
End If

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-IMP-LIRE-S] = variabile
rst_SMWFMX.Update
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''
'elab the shit
rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-IMP-LIRE-I] = variabile
rst_SMWFMX.Update

'variabile = rst_

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-IMP-LIRE-D] = variabile
rst_SMWFMX.Update

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-IMP-VAL-S] = variabile
rst_SMWFMX.Update

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-ANALITICA] = variabile
rst_SMWFMX.Update

rst_SMWFMX.Edit
rst_SMWFMX![SMWFMX-OPERAT] = rst_T001![OPERAT]
rst_SMWFMX.Update


rst_SMWFMX.MoveNext
rst_T002_FMX.MoveNext




Loop Until rst_T002_FMX.EOF
Jun 21 '07 #1
1 1852
MMcCarthy
14,534 Expert Mod 8TB
It's very difficult to follow the logic of what you are doing.

Can you describe your problem in terms of logic and forget about what you are doing with tables and code for a moment. You say you want to copy data from one table to another depending on some criteria. Why are you doing this? What is the structure of the two tables and what is the criteria for copying them?

In the meantime have a look at this tutorial, it might help.

Database Normalisation
Jun 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Caroline | last post by:
I need to update a table by copying a column from another table (having the same structure, but on another database), from the record having the same primary key. 1 - What is the correct...
21
by: Dan | last post by:
Hi, just ran into my first instance of a backend Access97 database not compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on compact. I've narrowed it down to the largest...
3
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock...
5
by: Lyn | last post by:
I am trying to copy selected fields from one table to another, by reading the source table record into a recordset (ADO) and then copying the relevant fields to an SQL statement "INSERT INTO...". ...
5
by: Nathan Sokalski | last post by:
I am writing an ASP.NET application in which I need to copy DataRows from one DataTable to another. When I use code such as the following: temprows = nodes.Select("state='PA'")...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
2
by: Debbie | last post by:
what is the SK values in the given code? X=f0ccaa0; Y=aaccf00; *SK++ = ((X << 4) & 0x24000000) | ((X << 28) & 0x10000000) | ((X << 14) & 0x08000000) | ((X << 18) & 0x02080000) | ((X <<...
6
by: Jeff Brooks | last post by:
I need to copy a record one access record into the same table. I just need to modify a couple fields that the user will change. Im sure there is an easy way to do it. I have started just reading...
1
by: lharenyam | last post by:
Hi, I nedd help copying values form one node to another Help copying values from one node to another -------------------------------------------------------------------------------- Hi, i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.