Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 7th, 2004, 08:47 AM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access VBA problem with Oracle database

Hi everyone,

I am using Access as an interface to an SQL Server database and an Oracle database.

What I do is I insert a new record in an ADODB recordset. Here is how I do it in SQL server:

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("select * from EAM_T where EAMID=someNum, dbOpenDynaset, dbSeeChanges)
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset

rs2.Open "Select * from EAM_T", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

rs2.AddNew
rs2![Name] = rs![Name]
rs2.Update
newID = rs2!EAMlID
rs2.Close

This always works fine in SQL server. Upon browsing a lot of documentation I found that you have to use Requery in Oracle for this to work. So, here is how I do it in Oracle:

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("select * from EAM_T where EAMID=someNum, dbOpenDynaset, dbSeeChanges)
Dim rs2 As ADODB.Recordset
Set rs2 = New ADODB.Recordset

rs2.Open "Select * from EAM_T", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs2.AddNew
rs2![Name] = rs![Name]
rs2.Update
bookmark = rs2.AbsolutePosition
rs2.Requery
rs2.AbsolutePosition = bookmark
newID = rs2!EAMID

This works most of the time. But sometimes it returns another ID, not the one that just existed. So, the newID is inserted in some position that is not the same after the requery. How can I make sure that the new record is always inserted at the end and this requery works fine. Basically, all I am trying to so is get the field value of a newly inserted row in Oracle.

Thanks,

Pankaj


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
INSERT into Access Database from VBA for Excel zuerlein Excel VBA 0 June 3rd, 2007 01:51 AM
Installing a access database program in VBA MDrumm Access 4 August 22nd, 2005 02:48 AM
HOW TO LINK ACCESS DATABASE TO ORACLE? pamma_lean Access 1 May 4th, 2005 10:11 AM
Access VBA with Oracle connection pankaj_daga Access 0 September 7th, 2004 08:48 AM
Beginning Access VBA 2002 Database File sristm BOOK: Beginning Access VBA 0 March 31st, 2004 12:08 AM



All times are GMT -4. The time now is 09:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.