Link to home
Start Free TrialLog in
Avatar of davidgfi
davidgfi

asked on

insert vba access using rst_insert.Fields("first") = rst_search.Fields("firstname")

I must do a kind of VBA procedure to select data from different tables to insert and my Director
wants me to use a specific access process to imitate in a way an ORACLE stored procedure cursor:

I've tried to find the codeing way on internet but if the cursor is available for what concerns the select
the insertion is not achieved

I've defined the query REQUERY:
SELECT manager.firstname, manager.lastname
FROM manager;

and T1 has two columns first and last.

The code is:



Private Sub Bascule2_Click()

Dim requete As String
Dim rst_search As Recordset
Dim rst_insert As Recordset
Dim rst_cum_fact_ytd As Recordset
Dim nom_collab As String
Dim pnom_collab As String
Dim datesortie_collab As String
Dim matricule_collab As String
Dim CYTD As Double

Set rst_search = CurrentDb.OpenRecordset("REQUERY")

 

      Set rst_insert = CurrentDb.OpenRecordset("T1", dbOpenTable)


If rst_search.RecordCount > 0 Then
    rst_search.MoveLast
    rst_search.MoveFirst
    Do




        rst_insert.AddNew

       
        rst_insert.Fields("first") = rst_search.Fields("firstname")
         rst_insert.Fields("last") = rst_search.Fields("lastname")
         
         'MsgBox rst_search.Fields("firstname")
       
        rst_search.MoveNext
         
Loop Until rst_search.EOF

End If

End Sub


I include the database where is the code (pres button insert into T1)
that an expert suggested me to do;


Thanks if you can help.

David
manager1.mdb
ASKER CERTIFIED SOLUTION
Avatar of frankytee
frankytee
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davidgfi
davidgfi

ASKER

Thanks a lot.
Sorry I did not ommit update by inadvertance but I learn very fast
microsoft with expert exchange for my new Job.

Best David
you're welcome.
Thanks,
Never knows maybe one day I can pretend to help others.
Best David