Solved

Validation Process

Posted on 2000-03-17
5
156 Views
Last Modified: 2010-05-02
If the END button is pressed I am trying to validate on a number of options, this includes trying to establish whether a Masked Edit box is actually blank or not. The code I am using does not appear to be doing the job. Can anyone see the problem with it

If tmpType = ("1") And _
frmSport1.Level1.Text = ("New Funding Enquiry") And _
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _
    msktxtEventDate.Text = ("") Or _
    txtProjectCost.Text = ("") Or _
    cmboBiddingStaging.Text = ("") Or _
    msktxtBidDeadline.Text = ("") Then
    Msg = "You have not completed the World Class Events Additional Information!"   ' Define message.
    Style = vbOKOnly + vbCritical ' Define buttons.
    Title = "Please Confirm"  ' Define title.
    Response = MsgBox(Msg, Style, Title)
    msktxtEventDate.SetFocus
End If
   
If frmSport1.Level1.Text = ("New Funding Enquiry") And _
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _
    msktxtEventDate.Text <> ("") Or _
    txtProjectCost.Text <> ("") Or _
    cmboBiddingStaging.Text <> ("") Or _
    msktxtBidDeadline.Text <> ("") Then
   
'after validity checks, sends data to clipboard for retrieval by teleconnect

Clipboard.SetText frmSport1.cmboTitle + CRLF + frmSport1.txtInit + CRLF + frmSport1.txtSurname + CRLF + frmSport1.txtPosition + CRLF + frmSport1.txtOrganisation + CRLF + frmSport1.txtAddress1 + CRLF + frmSport1.txtAddress2 + CRLF + frmSport1.txtAddress3 + CRLF + frmSport1.txtAddress4 + CRLF + frmSport1.txtPostcode + CRLF + frmSport1.txtTelephone1 + CRLF + frmSport1.txtTelephone2 + CRLF + frmSport1.ComboCallertype + CRLF + frmSport1.txtRegion + CRLF + frmSport1.txtLocalAuthority + CRLF + frmSport1.txtProject + CRLF + frmSport1.txtIntentDate + CRLF + frmSport1.txtDateClosed + CRLF + frmSport1.CmboAssignTo + CRLF + frmSport1.cmboPriority + CRLF + frmSport1.txtCallDets + CRLF + frmSport1.Level1 + CRLF + frmSport1.Level2 + CRLF + frmSport1.Level3 + CRLF + frmSport1.Level4 + CRLF + txtASpartnership + CRLF + txtASForm + CRLF + msktxtEventDate + CRLF + txtProjectCost _
+ CRLF + cmboBiddingStaging + CRLF + msktxtBidDeadline

End
End If
Else
End If
End Sub

Basically what happens is that if the End Button pressed and
msktxtEventDate  
txtProjectCost
cmboBiddingStaging
msktxtBidDeadline

are all blank it does not wait for the boxes to be filled, dumps to the clipboard and ends the program.
0
Comment
Question by:Mister_Simon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 

Expert Comment

by:pinshah
ID: 2627415
_
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _ (
    msktxtEventDate.Text <> ("") Or _
    txtProjectCost.Text <> ("") Or _
    cmboBiddingStaging.Text <> ("") Or _
    msktxtBidDeadline.Text <> ("")) Then
     

Just Add two parantheses. The problem is because of the precedence of the operator

0
 

Expert Comment

by:pinshah
ID: 2627427
sorry a little change . Apply to the first statement

If tmpType = ("1") And _
frmSport1.Level1.Text = ("New Funding Enquiry") And _
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _
    (msktxtEventDate.Text = ("") Or _
    txtProjectCost.Text = ("") Or _
    cmboBiddingStaging.Text = ("") Or _
    msktxtBidDeadline.Text = ("")) Then

'Error Message

I think you need to revise your checking.

are you not checking if data is proper in the level(n) text boxes?




   
0
 

Accepted Solution

by:
pinshah earned 35 total points
ID: 2627428
sorry a little change . Apply to the first statement

If tmpType = ("1") And _
frmSport1.Level1.Text = ("New Funding Enquiry") And _
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _
    (msktxtEventDate.Text = ("") Or _
    txtProjectCost.Text = ("") Or _
    cmboBiddingStaging.Text = ("") Or _
    msktxtBidDeadline.Text = ("")) Then

'Error Message

I think you need to revise your checking.

are you not checking if data is proper in the level(n) text boxes?




   
0
 

Author Comment

by:Mister_Simon
ID: 2627584
Thanks Pinshah, still needed a little refining to work properly. See Below

Out of interest why does the series of OR statements need double bracketing ?


If tmpType = ("1") And _
frmSport1.Level1.Text = ("New Funding Enquiry") And _
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _
    (msktxtEventDate.Text = ("__/__/____") Or _
    txtProjectCost.Text = ("") Or _
    cmboBiddingStaging.Text = ("") Or _
    msktxtBidDeadline.Text = ("__/__/____")) Then
    Msg = "You have not completed the World Class Events Additional Information!"   ' Define message.
    Style = vbOKOnly + vbCritical ' Define buttons.
    Title = "Please Confirm"  ' Define title.
    Response = MsgBox(Msg, Style, Title)
    msktxtEventDate.SetFocus
End If

If tmpType = ("1") And _
frmSport1.Level1.Text = ("New Funding Enquiry") And _
    frmSport1.Level2.Text = ("World Class - Revenue") And _
    frmSport1.Level3.Text = ("World Class Events") And _
    (msktxtEventDate.Text <> ("__/__/____") And _
    txtProjectCost.Text <> ("") And _
    cmboBiddingStaging.Text <> ("") And _
    msktxtBidDeadline.Text <> ("__/__/____")) Then
   
'after validity checks, sends data to clipboard for retrieval by teleconnect

Clipboard.SetText frmSport1.cmboTitle + CRLF + frmSport1.txtInit + CRLF + frmSport1.txtSurname + CRLF + frmSport1.txtPosition + CRLF + frmSport1.txtOrganisation + CRLF + frmSport1.txtAddress1 + CRLF + frmSport1.txtAddress2 + CRLF + frmSport1.txtAddress3 + CRLF + frmSport1.txtAddress4 + CRLF + frmSport1.txtPostcode + CRLF + frmSport1.txtTelephone1 + CRLF + frmSport1.txtTelephone2 + CRLF + frmSport1.ComboCallertype + CRLF + frmSport1.txtRegion + CRLF + frmSport1.txtLocalAuthority + CRLF + frmSport1.txtProject + CRLF + frmSport1.txtIntentDate + CRLF + frmSport1.txtDateClosed + CRLF + frmSport1.CmboAssignTo + CRLF + frmSport1.cmboPriority + CRLF + frmSport1.txtCallDets + CRLF + frmSport1.Level1 + CRLF + frmSport1.Level2 + CRLF + frmSport1.Level3 + CRLF + frmSport1.Level4 + CRLF + txtASpartnership + CRLF + txtASForm + CRLF + msktxtEventDate + CRLF + txtProjectCost _
+ CRLF + cmboBiddingStaging + CRLF + msktxtBidDeadline

End
End If
0
 
LVL 1

Expert Comment

by:phiro
ID: 2627587
Hmm, By giving the End command. the VB application  will drop everything and quit. No checking can be done after that because no events will be handled.
Better use the unload routine and let the Unload events of your forms do the work :

Dim f as Form

For each f in Forms
   Unload f
Next f

This will close your app in an ordely fashon.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question