Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-10
4
Medium Priority
?
574 Views
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_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
0
Comment
Question by:davidgfi
[X]
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
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
frankytee earned 2000 total points
ID: 21757090
you missed the update, it goes just before the movenext like below
'---------------------------------------------------------------------
        rst_insert.update
'---------------------------------------------------------------------
        rst_search.MoveNext        
etc
0
 

Author Closing Comment

by:davidgfi
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
0
 
LVL 19

Expert Comment

by:frankytee
ID: 21759588
you're welcome.
0
 

Author Comment

by:davidgfi
ID: 21760096
Thanks,
Never knows maybe one day I can pretend to help others.
Best David
0

Featured Post

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 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