ValidationRule causing problems

stormin_norm

Registered User.
Local time
Today, 06:27
Joined
Apr 23, 2003
Messages
213
HELP!
I'm getting the following error message:
Cannot add or change record because a related record is required in table 'Adult'


I have a form which was working great. I just added a validation rule on the table to ensure the user enter's the correct data. And now receive an error message.

background:
two tables- Adult and Grade with referential integrity set. StudentID is the field linking the two tables.

What I noticed:
If a correct grade is entered for a student, the Grade.StudentID autopopulates with the correct value (Adult.StudentID). GREAT!

If an incorrect grade is entered for a student then the validation text message warns the user the value is not correct, and then I see a zero in the Grade.StudentID column. However the Grade.GradeID is populated with a new rowid.

Why is it doing this?
:confused: :confused:

I guess the workaround is to check the values again onUpdate, and clear the Me.[GradeStudentID] field. Any other suggestions?
 
Norm,

Use the BeforeInsert event of your Grade form:

Code:
If IsNull(Me.GradeField) Then
   MsgBox("You must enter a grade."
   Me.GradeField.SetFocus
   Exit Sub
End If

Wayne
 
Now I get a runtime error 2108

"You must save the field before you execute the GoToControl ation, GoToControl method or the setFocus method."
 
ALSO---

I have an additional issue-
If I clear the student grade, let's say "B" to null/space. I want to clear the autonumber fields Grade.GradeID and Grade.StudentID, in other words, get rid of all data for that row.

I tried AfterUpdate:

If IsNull(Me![Grade]) Then
Me.ID.Undo
Me.CohortGradesStudentID.Undo
end if

No go. The fields stay populated.
 

Users who are viewing this thread

Back
Top Bottom