PC Review


Reply
Thread Tools Rate Thread

what is the code for deleting a new record?

 
 
=?Utf-8?B?YmFieV9zd2FsbG93?=
Guest
Posts: n/a
 
      28th Feb 2005
I have different subforms inside a form, while 2nd subform depends on the
number indicating on the 1st subform. That is, if there exists the number
"1", there should be only 1 record in the 2nd subform. I've already
constrained it with the following code:

Private Sub Seg__AfterUpdate()
If Me.Seg_ > [Forms]![PROJECT_Information]![Segments] Then
MsgBox "The maximum segment number can not be greater than the project's
segment number!"
End If
End Sub

but when I enter a "2" in the new record "Seg_", the new record exists for
user to enter data, that there are 3 rows (with 2 empty record) instead of
only 1 record that i want. What code should I insert in order to delete the
empty records (row) ? I also want to prevent people to insert anything except
for the correct number, can I make it to delete the new record when the error
message is shown?
Thank you everyone!
 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      1st Mar 2005
On Mon, 28 Feb 2005 11:51:01 -0800, baby_swallow
<(E-Mail Removed)> wrote:

>I have different subforms inside a form, while 2nd subform depends on the
>number indicating on the 1st subform. That is, if there exists the number
>"1", there should be only 1 record in the 2nd subform. I've already
>constrained it with the following code:
>
>Private Sub Seg__AfterUpdate()
> If Me.Seg_ > [Forms]![PROJECT_Information]![Segments] Then
> MsgBox "The maximum segment number can not be greater than the project's
>segment number!"
> End If
>End Sub
>
>but when I enter a "2" in the new record "Seg_", the new record exists for
>user to enter data, that there are 3 rows (with 2 empty record) instead of
>only 1 record that i want. What code should I insert in order to delete the
>empty records (row) ? I also want to prevent people to insert anything except
>for the correct number, can I make it to delete the new record when the error
>message is shown?
>Thank you everyone!


I'd recommend using the second subform's BeforeInsert event instead;
set its Cancel argument to True (with a user warning) *before* the
record is added, rather than letting the user add one and then
slapping their hand afterward.

John W. Vinson[MVP]
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Canceling and deleting a record via code – help please. FatMan Microsoft Access VBA Modules 4 14th Aug 2009 06:36 PM
Subform..Deleting a Record by code =?Utf-8?B?Qm9iIEJhcm5lcw==?= Microsoft Access 1 11th Nov 2007 03:22 PM
deleting a record in a subform from VBA code in the main form Paul James Microsoft Access Form Coding 2 8th Oct 2004 09:32 PM
Deleting Record with Code Eddy Microsoft Access Form Coding 1 12th Jun 2004 05:13 AM
Deleting a record with code Mark Microsoft Access 2 22nd Mar 2004 10:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 PM.