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