473,396 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Run Time Error-3021..Please help

I am developing a Address Book Database Project using Visual Basic 6...
When i click the delete button the data does'nt get deleted in the FrontEnd ..But it gets deleted in Database when we see in Access...
When i try to delete again in VB front End it gives a Error message and it gets

RUN time Error 3021
Either BOF or EOF is true,or current record has been deleted..Requested operation requires a current Record...

I am POSting the Entire Program below..Please Solve my Error





Expand|Select|Wrap|Line Numbers
  1. Dim intCurrAddress As Integer
  2. Dim intSaveupdate As Integer
  3.  
  4.  
  5. Private Sub LoadAddresses()
  6. Dim dbAddress As New ADODB.Connection
  7. Dim rsAddress As New ADODB.Recordset
  8. dbAddress.Open "dsn=Address"
  9. cboAddresses.Clear
  10.  
  11. Set rsAddress = dbAddress.Execute("select * from" & _
  12. " address order by txtLastName")
  13. intCurrAddress = rsAddress("idAddress")
  14. Do Until rsAddress.EOF
  15. cboAddresses.AddItem rsAddress("txtFirstName") & " " & rsAddress("txtLastName")
  16. cboAddresses.ItemData(cboAddresses.NewIndex) = rsAddress("idAddress")
  17. rsAddress.MoveNext
  18. Loop
  19. dbAddress.Close
  20. intSaveupdate = 0
  21. cboAddresses.ListIndex = 0
  22.  
  23. End Sub
  24.  
  25. Private Sub cboAddresses_click()
  26. Dim dbAddress As New ADODB.Connection
  27. Dim rsAddress As New ADODB.Recordset
  28. dbAddress.Open "dsn=Address"
  29.  
  30. If intSaveupdate = 1 Then
  31. SQL = "update address set " & _
  32. "txtFirstName ='" & TxtFirstName.Text & "'," & _
  33. "txtLastName ='" & TxtLastName.Text & "'," & _
  34. "txtAddress ='" & TxtAddress.Text & "'," & _
  35. "txtCity ='" & TxtCity.Text & "'," & _
  36. "txtState ='" & TxtState.Text & "'," & _
  37. "txtZipCode ='" & TxtZipCode.Text & "'," & _
  38. "txtPhone ='" & TxtPhone.Text & "'," & _
  39. "txtFax ='" & TxtFax.Text & "' where idaddress= " & intCurrAddress
  40. dbAddress.Execute SQL
  41. End If
  42. intCurrAddress = cboAddresses.ItemData(cboAddresses.ListIndex)
  43. Set rsAddress = dbAddress.Execute("select * " & "from address where idAddress= " & intCurrAddress)
  44.  
  45. LblIdAddress.Caption = rsAddress("idAddress")
  46. TxtFirstName.Text = rsAddress("txtFirstName")
  47. TxtLastName.Text = rsAddress("txtLastName")
  48. TxtAddress.Text = rsAddress("txtCity")
  49. TxtCity.Text = rsAddress("txtCity")
  50. TxtState.Text = rsAddress("txtState")
  51. TxtZipCode.Text = rsAddress("txtZipCode")
  52. TxtPhone.Text = rsAddress("txtPhone")
  53. TxtFax.Text = rsAddress("txtFax")
  54. dbAddress.Close
  55. End Sub
  56.  
  57. Private Sub CmdAdd_Click()
  58. CmdCancel.Enabled = True
  59. Cmdupdate.Enabled = True
  60. CmdAdd.Enabled = False
  61. cboAddresses.Enabled = False
  62. CmdAddress.Enabled = False
  63.  
  64. LblIdAddress.Caption = " "
  65. TxtFirstName.Text = " "
  66. TxtLastName.Text = " "
  67. TxtAddress.Text = " "
  68. TxtCity.Text = " "
  69. TxtState.Text = " "
  70. TxtZipCode.Text = " "
  71. TxtPhone.Text = " "
  72. TxtFax.Text = " "
  73. intSaveupdate = 0
  74. End Sub
  75. Private Sub CmdAddress_Click()
  76. rptAddress.Show
  77. End Sub
  78. Private Sub cmdupdate_click()
  79. Dim dbAddress As New ADODB.Connection
  80. Dim rsAddress As New ADODB.Recordset
  81. Cmdupdate.Enabled = False
  82. CmdAdd.Enabled = True
  83. cboAddresses.Enabled = True
  84. CmdAddress.Enabled = False
  85. dbAddress.Open "dsn=address"
  86. SQL = " insert into address(txtFirstName,txtLastName," & _
  87. "txtAddress," & _
  88. "txtCity,txtState,txtZipCode,txtPhone,txtFax)" & _
  89. " Values(' " & _
  90. TxtFirstName.Text & " ', ' " & _
  91. TxtLastName.Text & " ', ' " & _
  92. TxtAddress.Text & " ', ' " & _
  93. TxtCity.Text & " ', ' " & _
  94. TxtState.Text & " ', ' " & _
  95. TxtZipCode.Text & " ', ' " & _
  96. TxtPhone.Text & " ', ' " & _
  97. TxtFax.Text & " ')"
  98. dbAddress.Execute SQL
  99. dbAddress.Close
  100. LoadAddresses
  101. End Sub
  102. Private Sub cmddelete_click()
  103. Dim dbAddress As New ADODB.Connection
  104. Dim intResponse As Integer
  105. strResponse = MsgBox("Are You Sure?", vbYesNo, "Delete Query")
  106. If strResponse = 6 Then
  107. dbAddress.Open "dsn=address"
  108. SQL = "delete from address where idaddress= " & intCurrAddress
  109. dbAddress.Execute SQL
  110. LoadAddresses
  111.  
  112. dbAddress.Close
  113. End If
  114.  
  115. End Sub
  116.  
  117.  
  118. Private Sub cmdcancel_click()
  119. LoadAddresses
  120. cboAddresses.Enabled = True
  121. CmdAdd.Enabled = True
  122. Cmdupdate.Enabled = False
  123. CmdCancel.Enabled = False
  124. End Sub
  125.  
  126.  
  127. Private Sub Form_load()
  128. LoadAddresses
  129. End Sub
  130.  
Feb 28 '09 #1
0 1894

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Ken | last post by:
Hi. Can anyone refer me to any articles about the compatibility between c++ polymorphism and real-time programming? I'm currently on a real-time c++ project, and we're having a discussion...
5
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
13
by: cab0san | last post by:
I downloaded the DB2 runtime client, but the Client Base support and the TCP protocol do not install. I re-run the setup select them to run from disk, and they still show as not installed. What am...
27
by: Mike MacSween | last post by:
Some of my users are getting 'Disk or Network Errors'. I've raised it with the network admins, they're looking into it. In the meantime... My 'standard' error handlers logs errors to a table...
1
by: MLH | last post by:
I want to change my system time date each time an A97 app is started. Here's how I've been doing it. Am looking for a better way. Sure some of you have researched this. Function...
2
by: Glen | last post by:
I'm working on a custom assembly and I'm trying to figure out the best approach to handling known constraints within the assembly, once compiled, to alert the developer at compile time of a...
1
by: Alfonso Morra | last post by:
Hi I'm compiling some code and need to generate some random numbers. To save time, I decided to use the srand, rand and time functions. My code worked (atleast built fine) until I added time.h,...
21
by: rdemyan via AccessMonster.com | last post by:
Is there a way to get the internet date/time. I saw an article that uses WinSock, but WinSock doesn't seem to be available in Access. I want to verify that the date/time on the local PC running...
9
by: ThunderMusic | last post by:
Hi, I'd like to create a compile time error in my class... maybe there's a way already built in in the framework so I can achieve what I want... I have 2 constructors in my class. One of them...
4
by: ahmurad | last post by:
Dear Xperts, In my database table some fault code type records are inserted and the values are like bellows: Error:2/FC:10; 00:15:13 16/03/2009; Error:2/FC:20; 00:15:15 16/03/2009; ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.