Solved

Recorset not refreshed

Posted on 2002-04-24
6
193 Views
Last Modified: 2010-05-02
Hi everybody,

I want to insert 50 records in a table let us take it as table1 let us consider there are 3 columns out of which col1 is a primary . i am getting the max of col1 and adding 1 to the col1 and  inserting it into the table. Now when the loop is run, the first record is inserted after that it is giving error saying that record cannot be inserted because of the primarykey violation can anybody say how to perform this operation.

I think the recordset is not refreshed when I am getting max of col1


Thanks in advance

Regards
Pushparaj
0
Comment
Question by:v_pushparaj
6 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 50 total points
ID: 6966735
can you post some code? are you correctly incrementing the key?

ie: (pseudo code)

newKey = Max(col1)

while rs.eof = false
   rs.movenext
   rs.fields("col1") = newKey + 1
   rs.update
   newKey = newKey + 1
wend
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6967097
listening
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6967995
Give us
1-Ur Code
2- ADO Version
3- DBASE TYPE (ACCESS 97 OR OTHER)

to see if it is known bug
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Expert Comment

by:gron
ID: 6968208
What is the field definition for col1 ?
How are you establishing which one is "max" ?
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6971763
It should work if you have each of these operations in approximately this order:

For i = 1 to 50
' this function either searches through the recordset or
' goes back to the db and runs another query to get the max
  x = GetMaxKey()
  x = x + 1
  rs.Addnew
  rs("PKEY").Value = x
  rs("otherfield").Value = "somevalue"
  rs.Update
Next i
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6992866
Admin notified of User neglect. Force-accepted by
Netminder
CS Moderator
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now