473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

email validation fails

T
I have a db w/3 required fields, I'm using the follow code to validate
on the forms before update, which works fine. Problem is user are
selecting the command button, which sends out an email message, I
don't want the message sent out unless the required fields are filled
out.

I've tried a few different lines of code w/no success, the portion in
between ---------------

Private Sub cmdSendEmail_Click()
'ea of 3 controls under properties: All: Tags set to Required

Dim blnContinue As Boolean
Dim ctl As Control
blnContinue = True
For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If IsNull(ctl) Then
' If Nz(ctl, "") = "" Then Tried this too
MsgBox "Field(s)indicated in red must contain data. ",
vbCritical + vbOKOnly + vbDefaultButton1, "Required Information
Missing"
--------------------------------------------------------------------------------------------------
DoCmd.CancelEvent
Exit Sub
'Cancel = True
--------------------------------------------------------------------------------------------------
ctl.SetFocus
Exit For
End If
End If
Next ctl
Set ctl = Nothing

OpenEmailRequestFraser
End Sub

Any idea'ws
Jan 24 '08 #1
1 1386
You can't use CancelEvent in this context, because it's not a cancelable
event.

When your code performs the Exit For, it continues down and calls
OpenEmailRequestFraser, which is what you are trying to avoid.

Try something like this:

Dim blnContinue As Boolean
Dim ctl As Control
Dim bCancel = True

For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If IsNull(ctl) Then
bCancel = True
Exit For
End If
End If
Next ctl
Set ctl = Nothing

If bCancel Then
MsgBox "Fields ...
Else
OpenEmailRequestFraser
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"T" <te****@wideopenwest.comwrote in message
news:6a**********************************@e4g2000h sg.googlegroups.com...
>I have a db w/3 required fields, I'm using the follow code to validate
on the forms before update, which works fine. Problem is user are
selecting the command button, which sends out an email message, I
don't want the message sent out unless the required fields are filled
out.

I've tried a few different lines of code w/no success, the portion in
between ---------------

Private Sub cmdSendEmail_Click()
'ea of 3 controls under properties: All: Tags set to Required

Dim blnContinue As Boolean
Dim ctl As Control
blnContinue = True
For Each ctl In Me.Controls
If ctl.Tag = "Required" Then
If IsNull(ctl) Then
' If Nz(ctl, "") = "" Then Tried this too
MsgBox "Field(s)indicated in red must contain data. ",
vbCritical + vbOKOnly + vbDefaultButton1, "Required Information
Missing"
--------------------------------------------------------------------------------------------------
DoCmd.CancelEvent
Exit Sub
'Cancel = True
--------------------------------------------------------------------------------------------------
ctl.SetFocus
Exit For
End If
End If
Next ctl
Set ctl = Nothing

OpenEmailRequestFraser
End Sub
Jan 25 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
6
by: Darren | last post by:
I have a form that has 10 fields on it. I have made all of them "Required". I also am using vb if statements to decide whether or not each field should be on the page. I am using the vb to...
0
by: Brian Conway | last post by:
I am having some validation and insertion problems. I am using a date picker that takes the selected date and puts it to ("dd-MMM-yyyy") format, as this was the only format that Oracle would...
3
by: Gary Varga | last post by:
In the file WebUIValidation.js, when a postback that doesn't fail the validation has a javascript error saying summary is undefined in the ValidationSummaryOnSubmit function....
1
by: Niclas | last post by:
Hi, How do I indicate what field fails a validation, usually you see a red star next to the faild field on a form. Is this built in functionality in the valdaition controls or shall I code this...
2
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
11
by: Bob Bedford | last post by:
Hi all, we have many people that have registered to our newsletter and we are getting every time more people who the email is unavailable. It's there any technique to detect such unavailable...
1
by: MayoM | last post by:
My form has some simple validation in the Before Update event. If the validation fails the code ends with DoCmd.CancelEvent The form also has an Update command button. This simply runs ...
8
by: Bryan | last post by:
I want my business objects to be able to do this: class Person(base): def __init__(self): self.name = None @base.validator def validate_name(self): if not self.name: return
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.