?
Solved

Adding to rdoResultset

Posted on 1998-11-20
3
Medium Priority
?
329 Views
Last Modified: 2013-12-25
I have created a rdoResultset using VB 4.0 and filled the Resultset using select statement from SQL 6.0 server database.

When I want to add new record to a table I use the addnew method:

oRec.AddNew
oRec!IsBook = 1
oRec!Code = DoQuotes(ItemType)
oRec!Description = "Not set yet"
oRec.Update

mnItemTypeID = oRec!PKId ' this is the key
oRec.Close
Set oRec = Nothing

As you can see I need to retrieve the just entered and automatically assigned PKId. I expected the current record pointer to point to the newly created record, but it points to the first record in the recordset instead. Does the rdo work say way as DAO? What is my solution? I cant issue oRec.movelast due to multi-user limitation.
Please share your experience with RDO.
Thank you


0
Comment
Question by:misha051797
[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
3 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1497759
The .AddNew should init the key. Try grabbing it prior to the .Update. .Update commits the record in memory to disk. Any Automatic fields should be created when the .AddNew fires, NOT when the .Update triggers.
0
 

Author Comment

by:misha051797
ID: 1497760
Thank you,
but where is my record pointer is pointing to?
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 100 total points
ID: 1497761
Depends. During the interval between the .AddNew and .Update it should be pointing to the record you're building in memory. After the .Update I think it's undefined until you reposition the pointer.

You gotta remember that in Access type databases the record pointers and such are much less important than in flat file database like dBase/FoxPro. The record is referenced more by it's INDEX than by it's record number. This is one of the reasons that it is so *hard* to get record numbers, they're really meaningless in the context of an Access data structure. Once you get over this hump you'll find that the data is much easier to manipulate, why should *you* have to worry about what # the record is as long the the *program* gets the right data! It's actually *simpler* to just say "gimme *this*" and let the database worry about where it is.

When you do a SELECT * FROM you're grooming a fresh data set every time. The .MoveNext moves thru your selected data in the order that the SELECT returned it. This means that you don't have to worry about which is which.

If you need to return to a specific record use BOOKMARK to note where you were, but remember that the BOOKMARK will be invalid after the next SELECT statement.

M

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

741 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