473,385 Members | 1,630 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,385 software developers and data experts.

No Current Record error

using ACCESS 2003
This code should do what I want, and it seems to, but every time i run it it says:
No Current Record

when i ctrl+break it the debug get hung up on the end sub.

heres the code, any ideas? :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command16_Click()
  2. On Error GoTo Err_Command16_Click
  3. Dim i As Integer, cnt As Integer, varBk As String
  4. Dim intCriteriaCount As Integer, MyDB As Database, MyRS As Recordset
  5. Dim intCounter As Integer
  6.  
  7. varBk = Me.Bookmark
  8. cnt = Me!Combo17
  9.  
  10. For i = 0 To cnt - 1
  11. DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  12. DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  13. DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
  14.  
  15. Me!Text22 = Me!Text22 + 1
  16.  
  17. Next
  18.  
  19. intCriteriaCount = DCount("*", "FindDuplicatesWeeklyPoints")
  20. intCriteriaCount = intCriteriaCount / 2 + 1
  21.  
  22. 'Are there Records meeting the Criteria?
  23. If intCriteriaCount > 0 Then
  24.   Set MyDB = CurrentDb()
  25.   'Order by your Primary Key Ascending
  26.   Set MyRS = MyDB.OpenRecordset("SELECT * FROM  FindDuplicatesWeeklyPoints ORDER BY [Weekly Index]")
  27.   MyRS.MoveLast: MyRS.MoveFirst
  28.     For intCounter = 1 To intCriteriaCount - 1      'All but the Last Record
  29.       MyRS.Delete
  30.       MyRS.MoveNext
  31.     Next
  32. Exit_Command16_Click:
  33. Me.Bookmark = varBk
  34.  
  35.  
  36. Else
  37.   Exit Sub
  38. End If
  39.  
  40. MyRS.Close
  41. Exit Sub
  42.  
  43. Err_Command16_Click:
  44. MsgBox Err.Description
  45.  
  46. End Sub
  47.  
Mar 18 '07 #1
2 2157
MMcCarthy
14,534 Expert Mod 8TB
OK I've tidied up the code a bit. See if this works. If not let me know.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command16_Click()
  2. On Error GoTo Err_Command16_Click
  3. Dim i As Integer, cnt As Integer
  4. Dim varBk As String
  5. Dim intCriteriaCount As Integer
  6. Dim MyDB As Database
  7. Dim MyRS As Recordset
  8. Dim intCounter As Integer
  9.  
  10.    varBk = Me.Bookmark
  11.    cnt = Me!Combo17
  12.  
  13.    For i = 0 To cnt - 1
  14.       DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  15.       DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
  16.       DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
  17.       'Paste Append
  18.       Me!Text22 = Me!Text22 + 1
  19.    Next
  20.  
  21.    intCriteriaCount = DCount("*", "FindDuplicatesWeeklyPoints")
  22.    intCriteriaCount = intCriteriaCount / 2 + 1
  23.  
  24.    'Are there Records meeting the Criteria?
  25.    If intCriteriaCount > 0 Then
  26.       Set MyDB = CurrentDb()
  27.       'Order by your Primary Key Ascending
  28.       Set MyRS = MyDB.OpenRecordset("SELECT * FROM FindDuplicatesWeeklyPoints ORDER BY [Weekly Index]")
  29.       MyRS.MoveLast: MyRS.MoveFirst
  30.       For intCounter = 1 To intCriteriaCount - 1      'All but the Last Record
  31.          MyRS.Delete
  32.          MyRS.MoveNext
  33.       Next
  34.    End If
  35. Exit_Command16_Click:
  36.    Me.Bookmark = varBk
  37.    MyRS.Close
  38.    Exit Sub
  39.  
  40. Err_Command16_Click:
  41.    MsgBox Err.Description
  42.     Resume Exit_Command16_Click
  43.  
  44. End Sub
  45.  
Mar 18 '07 #2
sorry i haven't tried it, i actually managed to get it to work by changing:
Expand|Select|Wrap|Line Numbers
  1. If intCriteriaCount > 0 Then
to

Expand|Select|Wrap|Line Numbers
  1. If intCriteriaCount > 1 Then
what was changed in your code?


thanks for the help anyway
Mar 18 '07 #3

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

Similar topics

2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
3
by: hebandgene | last post by:
When I delete a record in a subform I get the warning that I'm about to delete a record, followed by an error "No current record." When I click OK obviously the record is deleted and it goes to...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several thousand inventory items. The user can enter a...
2
by: Tom Clavel | last post by:
Scratching my head. I am using the filter property on a combo box .AfterUpdate event to get to a single client record. This is causing a some strange behavior: As I enter a subform, I get a no...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
2
by: Ian | last post by:
I am trying to save the current record on a form before opening a report, doesn’t sound to hard does it? The code on a buttons on click event goes like this: DoCmd.DoMenuItem acFormBar,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.