Thread: DoCmd.GoToRecord, question
10-17-14, 13:19 #1Registered User
- Join Date
- Oct 2014
Unanswered: DoCmd.GoToRecord, question
I have a form that I use to enter data to a table. The user enters a 10 digit number in field1 and hopefully the same number in field2. There is a field3 that compares the two other fields and if they match, then field3 shows a "match" or if they dont match it shows a "failed" result. This is done using IIf in a query. I also have the field3 formated to turn green if it equals "Match" and it turns red if it equals "failed". This all works fine.
Currently once the last field is enetred, the form will advance to a new record. And this is fine but I want it to remain on the current record if the value in field3 is "failed" . This allows the user to make the needed corrections. If it is "matched" I want it to progress to a new record.
What is the best way to do this? Should I use something like DoCmd.GoToRecord, and if so how do I account for the field3 value?
I hope this makes sense
10-18-14, 16:34 #2Moderator
Provided Answers: 19
- Join Date
- Jun 2005
- Richmond, Virginia USA
The following will prevent the Current Record from being saved, pop a Messagebox up, explaining the problem, and return Focus to the second Control, until the two Controls match.
Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.field3 = "Failed" Then Cancel = True MsgBox "Field1 and Field2 Must Match!" Field2.SetFocus End If End Sub
Welcome to dBforums!
Linq ;0)>Hope this helps!
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007