Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End of a Recordset

Status
Not open for further replies.

regava

Programmer
May 24, 2001
152
US
When I click on the ADD command button I get the following error message from Microsoft Access (97):
"You can't go to the especified record.
You may be at the end of a recorset."
This error takes place specifically at "Docmd.GotoRecord , , acNewRec"
Does any body have an idea why this is taking place?
Help is appreciated. Thanks.
Rene.
 
Rene,
are you pulling your information from a table or a query?
Let me know
Scott ::)
 
Scott thank you for your reply.
I am pulling the information from a table. I do not know if there is a relevancy, but I thought I should mention it. Before I do the "GoToRecord" I open another table to get a unique number for this transanction. The Complete code follows (I though it will be better this way):
**************************************************************
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click

Dim db As Database
Dim rec As Recordset
Dim strYear As String
Dim lngNumber As Long
Dim strNumber As String
Dim strMessage As String
Dim strTitle As String
'Get the number for this transaction and update for next
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblTatno")
rec.Edit

' Save the year and Number
strYear = rec(0)
lngNumber = rec(1)

' Update the Number
rec(1) = rec(1) + 1
rec.Update
rec.Close

'strNumber = Right(Str(lngNumber), 4)
strNumber = Right(Format(lngNumber, "0000"), _
4 - (InStr(Format(lngNumber, "0000"), "0")))
strTitle = "TAT Tracking System"
strMessage = "The TAT No. for this Petitons is: " + _
"(" + [cmbLevel] + ")" + Right(strYear, 2) + "-" + _
strNumber + " (" + Left([cmbTax], 2) + ")"

MsgBox strMessage, vbInformation, strTitle

[Tatno] = strYear + Format(lngNumber, "0000") + " "
[RecordDate] = Date
[UpdateBy] = "Admin"

DoCmd.GoToRecord acDataTable, "tblTracking", acNewRec


Exit_Add_Record_Click:
Exit Sub

Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click

End Sub
**************************************************************
I do appreciate any help I can get. Once again thank you.
Rene.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top