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

Posted on 2008-06-10
Last Modified: 2011-10-19
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_insert.Fields("first") = rst_search.Fields("firstname")
         rst_insert.Fields("last") = rst_search.Fields("lastname")
         'MsgBox rst_search.Fields("firstname")
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.

Question by:davidgfi
  • 2
  • 2
LVL 19

Accepted Solution

frankytee earned 500 total points
ID: 21757090
you missed the update, it goes just before the movenext like below

Author Closing Comment

ID: 31466024
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
LVL 19

Expert Comment

ID: 21759588
you're welcome.

Author Comment

ID: 21760096
Never knows maybe one day I can pretend to help others.
Best David

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now