before update

Hi everyone.  I am using the following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Combo60 = True And  (Nz(Me.Personal_Data_Inaccuracies, 0)) + 
(Nz(Me.Improper_Combine, 0)) = 0 Then
   MsgBox "You selected yes to the Maintenance Issue question, therefore 
please select the number of errors in that section", vbCritical
   Cancel = False  ' Stop the process
End If
End Sub
If you try and save it prompts for the msgbox one time.  How can i make it 
so that the message comes up until they enter the required data or change the 
field to false?  Thanks.
0
Utf
11/28/2007 7:55:01 PM
access.forms 6864 articles. 2 followers. Follow

5 Replies
491 Views

Similar Articles

[PageSpeed] 53

Cancel = False has the effect of telling Access to ignore the line of code 
and go ahead with the update.  Cancel = True, on the other hand, will cancel 
the update (that is, the save won't happen).  Try something like:
Cancel = True
Me.Combo60.SetFocus

"scott04" <scott04@discussions.microsoft.com> wrote in message 
news:42644139-0DB6-4B40-9EE8-688C017AE2BE@microsoft.com...
> Hi everyone.  I am using the following code:
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> If Me.Combo60 = True And  (Nz(Me.Personal_Data_Inaccuracies, 0)) +
> (Nz(Me.Improper_Combine, 0)) = 0 Then
>   MsgBox "You selected yes to the Maintenance Issue question, therefore
> please select the number of errors in that section", vbCritical
>   Cancel = False  ' Stop the process
> End If
> End Sub
> If you try and save it prompts for the msgbox one time.  How can i make it
> so that the message comes up until they enter the required data or change 
> the
> field to false?  Thanks. 


0
BruceM
11/28/2007 8:10:33 PM
Bruce,
I tried what you suggested and it still allows me to save without going back 
to asking for the code again.

"BruceM" wrote:

> Cancel = False has the effect of telling Access to ignore the line of code 
> and go ahead with the update.  Cancel = True, on the other hand, will cancel 
> the update (that is, the save won't happen).  Try something like:
> Cancel = True
> Me.Combo60.SetFocus
> 
> "scott04" <scott04@discussions.microsoft.com> wrote in message 
> news:42644139-0DB6-4B40-9EE8-688C017AE2BE@microsoft.com...
> > Hi everyone.  I am using the following code:
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > If Me.Combo60 = True And  (Nz(Me.Personal_Data_Inaccuracies, 0)) +
> > (Nz(Me.Improper_Combine, 0)) = 0 Then
> >   MsgBox "You selected yes to the Maintenance Issue question, therefore
> > please select the number of errors in that section", vbCritical
> >   Cancel = False  ' Stop the process
> > End If
> > End Sub
> > If you try and save it prompts for the msgbox one time.  How can i make it
> > so that the message comes up until they enter the required data or change 
> > the
> > field to false?  Thanks. 
> 
> 
> 
0
Utf
11/28/2007 9:00:00 PM
What do you mean by "save without going back to ask for the code again"? 
Are you saying that if the user clicks the Save button again the record will 
be saved with no prompt for additional fields?
On another point, if "True" for Combo60 is a text value it needs to be in 
quotes.

"scott04" <scott04@discussions.microsoft.com> wrote in message 
news:1EC79808-D1F0-4CA2-8AA7-B49C8D34A855@microsoft.com...
> Bruce,
> I tried what you suggested and it still allows me to save without going 
> back
> to asking for the code again.
>
> "BruceM" wrote:
>
>> Cancel = False has the effect of telling Access to ignore the line of 
>> code
>> and go ahead with the update.  Cancel = True, on the other hand, will 
>> cancel
>> the update (that is, the save won't happen).  Try something like:
>> Cancel = True
>> Me.Combo60.SetFocus
>>
>> "scott04" <scott04@discussions.microsoft.com> wrote in message
>> news:42644139-0DB6-4B40-9EE8-688C017AE2BE@microsoft.com...
>> > Hi everyone.  I am using the following code:
>> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> > If Me.Combo60 = True And  (Nz(Me.Personal_Data_Inaccuracies, 0)) +
>> > (Nz(Me.Improper_Combine, 0)) = 0 Then
>> >   MsgBox "You selected yes to the Maintenance Issue question, therefore
>> > please select the number of errors in that section", vbCritical
>> >   Cancel = False  ' Stop the process
>> > End If
>> > End Sub
>> > If you try and save it prompts for the msgbox one time.  How can i make 
>> > it
>> > so that the message comes up until they enter the required data or 
>> > change
>> > the
>> > field to false?  Thanks.
>>
>>
>> 


0
BruceM
11/29/2007 12:15:56 PM
Bruce,
Sorry for not responding sooner.  The when you hit my command button to save 
or exit, the code runs and the message box pops up as it should.  If you hit 
ok to the msgbox and then hit save again it allows you to save the 
information.  

"BruceM" wrote:

> What do you mean by "save without going back to ask for the code again"? 
> Are you saying that if the user clicks the Save button again the record will 
> be saved with no prompt for additional fields?
> On another point, if "True" for Combo60 is a text value it needs to be in 
> quotes.
> 
> "scott04" <scott04@discussions.microsoft.com> wrote in message 
> news:1EC79808-D1F0-4CA2-8AA7-B49C8D34A855@microsoft.com...
> > Bruce,
> > I tried what you suggested and it still allows me to save without going 
> > back
> > to asking for the code again.
> >
> > "BruceM" wrote:
> >
> >> Cancel = False has the effect of telling Access to ignore the line of 
> >> code
> >> and go ahead with the update.  Cancel = True, on the other hand, will 
> >> cancel
> >> the update (that is, the save won't happen).  Try something like:
> >> Cancel = True
> >> Me.Combo60.SetFocus
> >>
> >> "scott04" <scott04@discussions.microsoft.com> wrote in message
> >> news:42644139-0DB6-4B40-9EE8-688C017AE2BE@microsoft.com...
> >> > Hi everyone.  I am using the following code:
> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > If Me.Combo60 = True And  (Nz(Me.Personal_Data_Inaccuracies, 0)) +
> >> > (Nz(Me.Improper_Combine, 0)) = 0 Then
> >> >   MsgBox "You selected yes to the Maintenance Issue question, therefore
> >> > please select the number of errors in that section", vbCritical
> >> >   Cancel = False  ' Stop the process
> >> > End If
> >> > End Sub
> >> > If you try and save it prompts for the msgbox one time.  How can i make 
> >> > it
> >> > so that the message comes up until they enter the required data or 
> >> > change
> >> > the
> >> > field to false?  Thanks.
> >>
> >>
> >> 
> 
> 
> 
0
Utf
11/30/2007 1:59:01 PM
I have done some testing, and cannot duplicate the problem.  Your code 
should be something like:
If Me.Combo60 = True And  _
    (Nz(Me.Personal_Data_Inaccuracies, 0)) + _
    (Nz(Me.Improper_Combine, 0)) = 0 Then
        MsgBox "You selected yes to the Maintenance Issue question, 
therefore " & _
            "please select the number of errors in that section", vbCritical
        Cancel = True
End If

By the way, you may need to trap the error that occurs in the comman button 
code when you cannot save the record.

Before you attempt to save a new or changed record, the record's "Dirty" 
property is True.  If you cancel the update, the record is not saved; its 
"Dirty" property is still True.  If you try again to save the record, the 
same thing should occur as when you first tried to save the record.  What is 
the exact code you are using in Before Update?

"scott04" <scott04@discussions.microsoft.com> wrote in message 
news:7BED2463-CF3E-40CC-8346-284352ACA739@microsoft.com...
> Bruce,
> Sorry for not responding sooner.  The when you hit my command button to 
> save
> or exit, the code runs and the message box pops up as it should.  If you 
> hit
> ok to the msgbox and then hit save again it allows you to save the
> information.
>
> "BruceM" wrote:
>
>> What do you mean by "save without going back to ask for the code again"?
>> Are you saying that if the user clicks the Save button again the record 
>> will
>> be saved with no prompt for additional fields?
>> On another point, if "True" for Combo60 is a text value it needs to be in
>> quotes.
>>
>> "scott04" <scott04@discussions.microsoft.com> wrote in message
>> news:1EC79808-D1F0-4CA2-8AA7-B49C8D34A855@microsoft.com...
>> > Bruce,
>> > I tried what you suggested and it still allows me to save without going
>> > back
>> > to asking for the code again.
>> >
>> > "BruceM" wrote:
>> >
>> >> Cancel = False has the effect of telling Access to ignore the line of
>> >> code
>> >> and go ahead with the update.  Cancel = True, on the other hand, will
>> >> cancel
>> >> the update (that is, the save won't happen).  Try something like:
>> >> Cancel = True
>> >> Me.Combo60.SetFocus
>> >>
>> >> "scott04" <scott04@discussions.microsoft.com> wrote in message
>> >> news:42644139-0DB6-4B40-9EE8-688C017AE2BE@microsoft.com...
>> >> > Hi everyone.  I am using the following code:
>> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >> > If Me.Combo60 = True And  (Nz(Me.Personal_Data_Inaccuracies, 0)) +
>> >> > (Nz(Me.Improper_Combine, 0)) = 0 Then
>> >> >   MsgBox "You selected yes to the Maintenance Issue question, 
>> >> > therefore
>> >> > please select the number of errors in that section", vbCritical
>> >> >   Cancel = False  ' Stop the process
>> >> > End If
>> >> > End Sub
>> >> > If you try and save it prompts for the msgbox one time.  How can i 
>> >> > make
>> >> > it
>> >> > so that the message comes up until they enter the required data or
>> >> > change
>> >> > the
>> >> > field to false?  Thanks.
>> >>
>> >>
>> >>
>>
>>
>> 


0
BruceM
12/3/2007 4:54:25 PM
Reply:

Similar Artilces: