Re: rs.AddNew or DBEngine(0)(0).Execute revisited
- From: John W. Vinson <jvinson@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 Apr 2008 17:01:28 -0600
On Thu, 24 Apr 2008 09:07:40 -0700 (PDT), "pietlinden@xxxxxxxxxxx"
<pietlinden@xxxxxxxxxxx> wrote:
My form is based on the "Enrollment" table. and then that table has
child tables.
I can check for the existence of records in Student and Course just
fine and create enrollment records using .Execute if no arguments are
left blank. I was thinking I needed that because I wanted to know if
the insert succeeded by getting the .RecordsAffected property of the
Execute (?) command.
I wouldn't be inserting records using an append query at all! Why not simply
bind the form to the enrollment table (so any data entered will go right into
the table)? If you do so you can check the StudentID and CourseID controls in
the form's BeforeUpdate event, and cancel the update with a warning message if
either is null.
Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If IsNull(Me!cboStudent) Then
iAns = MsgBox("Please select a student or choose Cancel to start over", _
vbOKCancel)
Cancel = True ' cancel this addition in any case
If iAns = vbCancel Then
Me.Undo ' erase the form completely if requested
End If
End If
<do the same for cboClass>
--
John W. Vinson [MVP]
.
- Follow-Ups:
- Re: rs.AddNew or DBEngine(0)(0).Execute revisited
- From: pietlinden@xxxxxxxxxxx
- Re: rs.AddNew or DBEngine(0)(0).Execute revisited
- From: pietlinden@xxxxxxxxxxx
- Re: rs.AddNew or DBEngine(0)(0).Execute revisited
- References:
- rs.AddNew or DBEngine(0)(0).Execute revisited
- From: pietlinden@xxxxxxxxxxx
- rs.AddNew or DBEngine(0)(0).Execute revisited
- Prev by Date: Re: New record in subform with Access 2000
- Next by Date: query criteria
- Previous by thread: rs.AddNew or DBEngine(0)(0).Execute revisited
- Next by thread: Re: rs.AddNew or DBEngine(0)(0).Execute revisited
- Index(es):
Relevant Pages
|