Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form entry and SQL

Status
Not open for further replies.

evergrean100

Technical User
Dec 1, 2006
115
US
I have a Form with an POC Firstname, POC Lastname and Expert Firstname and Expert Lastname.
Sometimes the POC and Expert are the same person.
Code:
<form ....>
POC firstname: <input name="pocFirstname"....>
POC lastname: <input name="pocLastname"....>
Expert firstname: <input name="expertFirstname"....>
Expert lastname: <input name="expertLastname"....>
</form>

My Access 2003 table (ContactTable ) looks like this:
Code:
contact_id -> primary key
firstname 
lastname 
poc 
expert

Now for the Insert Query I need help because not sure if this is the best way to do this:
Code:
<cfif form.pocFirstname neq form.expertFirstname and form.pocLastname neq form.expertLastname>
INSERT INTO ContactTable
(firstname, lastname,poc,expert)
VALUES
('#form.pocFirstname#', '#form.pocLastname#','yes','no');

INSERT INTO ContactTable
(firstname, lastname,poc,expert)
VALUES
('#form.expertFirstname#', '#form.expertLastname#', 'no','yes');
<else>
<!--- POC and Expert are the same person so I can use poc (or expert) form entry for the SQL insert --->
INSERT INTO ContactTable
(firstname, lastname,poc,expert)
VALUES
('#form.pocFirstname#', '#form.pocLastname#', 'yes','yes');
</cfif>
 
What you are doing is fine. However, not sure about the "neq" condition you have. I would use this instead...
<cfif form.pocFirstname is form.expertFirstname and form.pocLastname is form.expertLastname>
<!--- POC and Expert are the same person so I can use poc (or expert) form entry for the SQL insert --->
INSERT INTO ContactTable
(firstname, lastname,poc,expert)
VALUES
('#form.pocFirstname#', '#form.pocLastname#', 'yes','yes');
<cfelse>
INSERT INTO ContactTable
(firstname, lastname,poc,expert)
VALUES
('#form.pocFirstname#', '#form.pocLastname#','yes','no');
INSERT INTO ContactTable
(firstname, lastname,poc,expert)
VALUES
('#form.expertFirstname#', '#form.expertLastname#', 'no','yes');
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top