Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 7th, 2004, 08:48 AM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access VBA with Oracle connection

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


Reply With Quote
Reply


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
Oracle Connection teddyk ASP.NET 2.0 Basics 1 October 6th, 2008 06:08 PM
oracle connection silvia C# 4 January 17th, 2006 08:12 AM
Connection between Access XP and Oracle Tachyophan Access 1 February 14th, 2005 10:45 AM
Begging Access 2003 VBA Ch 5 - connection problem Quixote BOOK: Beginning Access VBA 2 February 3rd, 2005 06:45 PM
Access VBA problem with Oracle database pankaj_daga Oracle 0 September 7th, 2004 08:47 AM



All times are GMT -4. The time now is 11:27 PM.


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