[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Adding to rdoResultset

Posted on 1998-11-20
3
Medium Priority
?
340 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

649 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