Solved

How do I validate two fields instead of one

Posted on 2014-09-29
6
143 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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