Run Append Query after update (1 Viewer)

urobee

Registered User.
Local time
Today, 04:50
Joined
Aug 12, 2019
Messages
20
Hy,
I have two table: "Master" and "Temp"
The form save the records in to "Temp" table.
I made the append Query it works fine when I run it manually.
Is there any option to run the append query automatically after form update/or before close to save the records to the "Master" table too?
Thanks!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:50
Joined
May 7, 2009
Messages
19,229
why not use Master table directly?
 

urobee

Registered User.
Local time
Today, 04:50
Joined
Aug 12, 2019
Messages
20
I need the "Temp" table to collect data until it reach 30 records then I make a report and clear the table and start it again. In the "Master" table I collect all the data without clear any records.
---------

EDIT:
I made an event on close form with macro builder so i was able to add the query i want to use.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:50
Joined
May 7, 2009
Messages
19,229
so the form is for data entry only?
add a button that will save your 30 entries to Master table and at the same time
clear the Temp table:
on the buttons (caption maybe "Save to Master and Clear"), add code to it's Click Event:
Code:
Private Sub yourButtonName_Click()
    Dim i as Integer
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = Currentdb
    Set rs = db.Openrecordset("Master", dbOpenDynaset) 
    With Me.RecodsetClone
        .MoveFirst
        While Not .EOF
            rs.AddNew
            For i = 0 to .Fields.Count -1
               rs.Fields(.Fields(i).Name) = .Fields(i)
            Next
            rs.Update
            .MoveNext
        Wend
        .MoveLast
        While Not .BOF
           .Delete
           .MovePrevious
        Wend
    End With
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:50
Joined
May 7, 2009
Messages
19,229
have you already tried it?
youre welcome!
 

urobee

Registered User.
Local time
Today, 04:50
Joined
Aug 12, 2019
Messages
20
so the form is for data entry only?
add a button that will save your 30 entries to Master table and at the same time
clear the Temp table:
on the buttons (caption maybe "Save to Master and Clear"), add code to it's Click Event:
Code:
Private Sub yourButtonName_Click()
    Dim i as Integer
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = Currentdb
    Set rs = db.Openrecordset("Master", dbOpenDynaset) 
    With Me.RecodsetClone
        .MoveFirst
        While Not .EOF
            rs.AddNew
            For i = 0 to .Fields.Count -1
               rs.Fields(.Fields(i).Name) = .Fields(i)
            Next
            rs.Update
            .MoveNext
        Wend
        .MoveLast
        While Not .BOF
           .Delete
           .MovePrevious
        Wend
    End With
End Sub

Hy,
today I've tried to use your code but i got this error message: "Method or data member not found" and this part is selected: Me.RecodsetClone
Access 2010 and here are the activated references:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:50
Joined
May 7, 2009
Messages
19,229
I don't know if it exists in a2010. you could replace it with Me.Recordset.Clone or just Me.Recordset.
 

Minty

AWF VIP
Local time
Today, 03:50
Joined
Jul 26, 2013
Messages
10,368
@Arne - Its a typo missing an r - RecordsetClone
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:50
Joined
May 7, 2009
Messages
19,229
good eyes.
there is also another one:

With Me.RecodsetClone

should be:

With Me.RecordsetClone

**
I tested it before posting. something is eating my "r".
 

Users who are viewing this thread

Top Bottom