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? : -
Private Sub Command16_Click()
-
On Error GoTo Err_Command16_Click
-
Dim i As Integer, cnt As Integer, varBk As String
-
Dim intCriteriaCount As Integer, MyDB As Database, MyRS As Recordset
-
Dim intCounter As Integer
-
-
varBk = Me.Bookmark
-
cnt = Me!Combo17
-
-
For i = 0 To cnt - 1
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
-
-
Me!Text22 = Me!Text22 + 1
-
-
Next
-
-
intCriteriaCount = DCount("*", "FindDuplicatesWeeklyPoints")
-
intCriteriaCount = intCriteriaCount / 2 + 1
-
-
'Are there Records meeting the Criteria?
-
If intCriteriaCount > 0 Then
-
Set MyDB = CurrentDb()
-
'Order by your Primary Key Ascending
-
Set MyRS = MyDB.OpenRecordset("SELECT * FROM FindDuplicatesWeeklyPoints ORDER BY [Weekly Index]")
-
MyRS.MoveLast: MyRS.MoveFirst
-
For intCounter = 1 To intCriteriaCount - 1 'All but the Last Record
-
MyRS.Delete
-
MyRS.MoveNext
-
Next
-
Exit_Command16_Click:
-
Me.Bookmark = varBk
-
-
-
Else
-
Exit Sub
-
End If
-
-
MyRS.Close
-
Exit Sub
-
-
Err_Command16_Click:
-
MsgBox Err.Description
-
-
End Sub
-
2 2157
OK I've tidied up the code a bit. See if this works. If not let me know. -
Private Sub Command16_Click()
-
On Error GoTo Err_Command16_Click
-
Dim i As Integer, cnt As Integer
-
Dim varBk As String
-
Dim intCriteriaCount As Integer
-
Dim MyDB As Database
-
Dim MyRS As Recordset
-
Dim intCounter As Integer
-
-
varBk = Me.Bookmark
-
cnt = Me!Combo17
-
-
For i = 0 To cnt - 1
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
-
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70
-
'Paste Append
-
Me!Text22 = Me!Text22 + 1
-
Next
-
-
intCriteriaCount = DCount("*", "FindDuplicatesWeeklyPoints")
-
intCriteriaCount = intCriteriaCount / 2 + 1
-
-
'Are there Records meeting the Criteria?
-
If intCriteriaCount > 0 Then
-
Set MyDB = CurrentDb()
-
'Order by your Primary Key Ascending
-
Set MyRS = MyDB.OpenRecordset("SELECT * FROM FindDuplicatesWeeklyPoints ORDER BY [Weekly Index]")
-
MyRS.MoveLast: MyRS.MoveFirst
-
For intCounter = 1 To intCriteriaCount - 1 'All but the Last Record
-
MyRS.Delete
-
MyRS.MoveNext
-
Next
-
End If
-
Exit_Command16_Click:
-
Me.Bookmark = varBk
-
MyRS.Close
-
Exit Sub
-
-
Err_Command16_Click:
-
MsgBox Err.Description
-
Resume Exit_Command16_Click
-
-
End Sub
-
sorry i haven't tried it, i actually managed to get it to work by changing: - If intCriteriaCount > 0 Then
to - If intCriteriaCount > 1 Then
what was changed in your code?
thanks for the help anyway
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
| |