Solved

Validation Process

Posted on 2000-03-17
5
151 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
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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