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

You can't go to the specified record error 1

Status
Not open for further replies.

surfbum3000

Technical User
Aug 22, 2003
156
US
I have a simple phonebook database which includes tblPhonebook and frmAdd. I am trying to prevent erroneous data from being entered. I set the validation rule for the PhoneNumber field in tblPhonebook to

Like "(281)*" Or Like "(713)*" Or Like "(800)*" Or Like "(832)*" Or Like "(903)*"

Validation Text: "You Have Entered An Invalid Phone Number"

When testing, I enter a fake number such as 888-888-8888. I get the Validation Text message. Click OK. So far so good. A second error then appears "The value in the record or field violates the validation rule for the record or field". Click OK. (I don't need this error message to appear since I have already notified the user with the previous message.) I am then returned to the phone number field. I change the phone number to a valid number. Then click Add Record (command button) which produces another window "Do you want to add this record?" Click OK. Then I get "You can't go to the specified record".

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim ctl As Control
On Error GoTo Err_BeforeUpdate

If Me.Dirty Then
If MsgBox("Do you want to add this new staff?", vbYesNo + vbQuestion, _
"Save Record") = vbNo Then
Me.undo
End If
End If

Exit_BeforeUpdate:
Exit Sub

Err_BeforeUpdate:
MsgBox Err.Number & " " & Err.Description
Resume Exit_BeforeUpdate
End Sub
 
Hallo,

What code do you have in your command button?
Do you have any other events on controls, or a table or form control validation rule?

If you do CTRL-BREAK when the errors are displayed does that give any clues?


- Frink
 
You may try to replace this:
Me.undo
with this:
Cancel = True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I made the following change:
Me.undo
with this:
Cancel = True

Thanks! I works fine now. Another problem I discovered is I forgot I added a validation rule to the field itself in the form. This was not necessary since I already had the validation rule in the table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top