?
Solved

How do I validate two fields instead of one

Posted on 2014-09-29
6
Medium Priority
?
146 Views
Last Modified: 2014-10-05
Can someone assist me with the correct syntax for validating two fields in a database table. The attached document details the code I am using which works and validates if a payment method already exists in my table e.g. Cash, Credit Card etc (i.e. a single field). What I want to do before I save my record is to validate if two fields in the same table exist e.g. How Paid and Payment Category. So if "Cash" (How Paid) and "General" (Payment Category) exists I want to display that this record already exists. I have tried adding the extra code but get compile errors. In the attached code I need to include Me.PaymentCategory.Text somehow/somewhere with Me.HowPaid.Text so that it checks to see if both exist in the one record. I am using Ironspeed Designer with a MSSQL 2012 backend database.
Validate.doc
0
Comment
Question by:sdms2004
[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
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 40349664
I'd post a text file rather than a doc file - less likely to have malware embedded in it.  (I'm not going to look into your attachment).

>>So if "Cash" (How Paid) and "General" (Payment Category) exists I want to display that this record already exists.

A simple and condition for an if statment, something like

IF HowPaid = "Cash" AND PaymentCategory = general THEN  
  'record exists - warn user
ELSE
  'add a new record
END IF
0
 

Author Comment

by:sdms2004
ID: 40350018
Thanks Andy, sorry about the word doc. I understand the principle but its the syntax. I have attached the code I am using in a plain text file
Steve
0
 

Author Comment

by:sdms2004
ID: 40350026
Andy
Forgot to attach the file
Steve
validate.txt
0
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

 
LVL 44

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 40350170
No need to apologise.

>>Dim whereStr As String = SD12HowPaidTable.HowPaid.InternalName & "='" & Me.HowPaid.Text & "'"

I think something like the following should be OK (the devil is in the details):

Dim whereStr As String = SD12HowPaidTable.HowPaid.InternalName & "='" & Me.HowPaid.Text & "' AND " & SD12HowPaidTable.PaymentCategory & "=general"
I don't know how you define the general (integer, text...) or how you have named things but the principal is just connect the parts of the where clause with an AND.  (also things like OR and NOT should be supported if you required those for other conditions).
0
 

Author Comment

by:sdms2004
ID: 40358330
Andy
Thanks, I will try it tonight when I get home and let you know how I go.
Steve
0
 

Author Comment

by:sdms2004
ID: 40362085
Andy
Thanks for pointing me in the right direction, got it to work
Steve
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 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