Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Validation Process

Posted on 2000-03-17
5
Medium Priority
?
159 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 140 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

721 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