Solved

How do I validate two fields instead of one

Posted on 2014-09-29
6
132 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
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
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
Comment Utility
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
Comment Utility
Andy
Forgot to attach the file
Steve
validate.txt
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
Comment Utility
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
Comment Utility
Andy
Thanks, I will try it tonight when I get home and let you know how I go.
Steve
0
 

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How Can I fix my MouseHover Event? 14 26
VB.net PaintEventArgs Handling. 10 26
Code enhancement 5 12
String manipulation 15 49
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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now