Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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