Solved

Validation Process

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 64
vb6 connector to mongodb 2 117
SQL VB connection works in one PC and doesn't in another 15 67
Help me. 3 60
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

809 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