473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stop a macro is the After Update Validation fails

5 New Member
Hi,
This problem has been bugging me for a while. In my form's before update field i have the following code:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.Nominator_name = "" Or IsNull(Me.Nominator_name) Then
MsgBox "Please fill in your name", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
Me.Nominator_name.SetFocus
DoCmd.CancelEvent
Exit Sub
End If

If Me.Nominee_name = "" Or IsNull(Me.Nominee_name) Then
MsgBox "Please choose an award nominee", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
Me.Nominee_name.SetFocus
DoCmd.CancelEvent
Exit Sub
End If

If Me.List30 = "" Or IsNull(Me.List30) Then
MsgBox "Please choose an award category", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
Me.List30.SetFocus
DoCmd.CancelEvent
Exit Sub
End If

End Sub

I also have a macro running on my command button which closes the current form and opens another. When i press the command button and the form has a null field the macro still runs and produces an error message.
How do i get the macro to stop running if the verification fails????!!!!?????
Apr 4 '07 #1
1 3386
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi,
This problem has been bugging me for a while. In my form's before update field i have the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  
  3. If Me.Nominator_name = "" Or IsNull(Me.Nominator_name) Then
  4. MsgBox "Please fill in your name", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
  5. Me.Nominator_name.SetFocus
  6. DoCmd.CancelEvent
  7. Exit Sub
  8. End If
  9.  
  10. If Me.Nominee_name = "" Or IsNull(Me.Nominee_name) Then
  11. MsgBox "Please choose an award nominee", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
  12. Me.Nominee_name.SetFocus
  13. DoCmd.CancelEvent
  14. Exit Sub
  15. End If
  16.  
  17. If Me.List30 = "" Or IsNull(Me.List30) Then
  18. MsgBox "Please choose an award category", vbCritical + vbOKOnly + vbDefaultButton2, "MISSING DATA"
  19. Me.List30.SetFocus
  20. DoCmd.CancelEvent
  21. Exit Sub
  22. End If
  23.  
  24. End Sub
  25.  
I also have a macro running on my command button which closes the current form and opens another. When i press the command button and the form has a null field the macro still runs and produces an error message.
How do i get the macro to stop running if the verification fails?
What is the code behind the command button?
Apr 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
1450
by: effendi | last post by:
I wrote a very simple validation fucntion to check if all fields are entered properly in a dialog box before returning this the values to the parent form. The validation works finr however, I am...
4
4048
by: welie | last post by:
I have a problem canceling a check box update when placing a check in it. Checkbox is not bound. Here is what happens. User clicks a check box. In the BeforeUpdate method of the control, if...
9
15383
by: Matt | last post by:
In many places in my application, I have a DataGridView which users can either enter data into or use as a method of navigation in a master/detail form view. I need a method of stopping the user...
1
1816
by: Rajani | last post by:
Hi, I have designed a form which process database Insert, edit and Delete(datagrid). I input userid,password and privilege in textboxes which has validation controls to verify data keyed in....
2
1802
by: Rajani | last post by:
Hi, I have designed a form which process database Insert, edit and Delete(datagrid). I input userid,password and privilege in textboxes which has validation controls to verify data keyed in....
6
6424
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
16
3462
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
11
6044
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.