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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2105 You can't go to specified record error

Status
Not open for further replies.

JFofOH

Technical User
Jun 4, 2012
2
US
I'm having problems with the 2105 Can't go to the specified record in my error handler. I added the MsgBox Err.Description to find out what the problem was that wouldn't let me save and go to the new record. All information is filled in and the error doesn't occur for every record. Anyone have any ideas?


If Me.txtTotaledScrap <> Me.txtScrap Then
MsgBox "Totals aren't equal to Scrap pieces, please check quantities"
Else
On Error GoTo ErrorHandler
Dim strMsg As String, strTitle As String
strMsg = "Do You Want To Save This Record?"
strTitle = " Save Record ?"
If MsgBox(strMsg, vbQuestion + vbYesNo, strTitle) = vbNo Then
Me.Undo
ExitErrorHandler:
Exit Sub
ErrorHandler:
MsgBox Err.Description
MsgBox "Please make sure all information is entered"
Resume ExitErrorHandler
End If
DoCmd.GoToRecord , , acNewRec
End If
'Bunch of visibility controls right here
End Sub
 
Hard to tell from what you posted, but usually that error is returned when you attempt to go to a new record on a form where Add Records is turned off.
 
The lines
Code:
On Error GoTo ErrorHandler
Dim strMsg As String, strTitle As String

need to be at the top of the Sub, i.e. immediately after the Sub Header, not down in the Else Clause, where you've got them.

And if your intent, as per your MessageBox, is that
Totals aren't equal to Scrap pieces
why does your test pop the warning

If txtTotaledScrap 'is not equal to' txtScrap

rather than

If txtTotaledScrap 'is equal to' txtScrap?

Linq ;0)>

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
Thanks for the suggestion on moving the On Error and Dim statements, I took your advice and did so.

My message box lets the user know that they did not enter enough scrap reasons to equal the amount of scrap they produced for the run. I have a hidden box of reasons that populates when they enter anything higher than 0. All reasons are defaulted to 0 and they enter how many were bad based on the reason. When all is said and done those need to equal the initial scrap they reported that opened that set of controls.

I find that the error only occurs when a record is duplicated to some degree. Say if I select the same press, tool and material as the previous record but put different quantities in, it will error, but if i go back and change a material it will save. I have autonumber id's and that is the only index. So it shouldn't create a unique value or interfere with the index. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top