troubleshooting Question

Insert data into correct Access field as a result of selection made

Avatar of arendt73
arendt73 asked on
Microsoft AccessASPSQL
5 Comments1 Solution243 ViewsLast Modified:
I am having issues inserting information into the correct table of an Access database after submission.  

What I am trying to do is insert data correctly into one of four tables.  This is dependent upon the submitter making a selection in the Location area of the submittal page.  

Below is my code for review.  My page was written in ASP.

<%
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("\ncb9009\registration\db\ncb.mdb") & ""
set conn = server.createobject("adodb.connection")
conn.open strconn

if request.form("location") = "TPA" Then
SQL = "insert into TPA (manager, program_title, event_date, event_time, event_duration, cle_credit, video, add_comments) values ('"& request.Form("manager") &"', ' "& request.Form("program_title") &" ', ' "& request.Form("event_date") &" ', ' "& request.Form("event_time") &"', ' "& request.Form("event_duration") &" ', ' "& request.Form("cle_credit") &" ', ' "& request.Form("video") &" ', ' "& request.Form("add_comments") &"')"
ELSE
if request.form("location") = "ORL" Then
SQL = "insert into ORL (manager, program_title, event_date, event_time, event_duration, cle_credit, video, add_comments) values ('"& request.Form("manager") &"', ' "& request.Form("program_title") &" ', ' "& request.Form("event_date") &" ', ' "& request.Form("event_time") &"', ' "& request.Form("event_duration") &" ', ' "& request.Form("cle_credit") &" ', ' "& request.Form("video") &" ', ' "& request.Form("add_comments") &"')"
ELSE
if request.form("location") = "JAX" Then
SQL = "insert into JAX (manager, program_title, event_date, event_time, event_duration, cle_credit, video, add_comments) values ('"& request.Form("manager") &"', ' "& request.Form("program_title") &" ', ' "& request.Form("event_date") &" ', ' "& request.Form("event_time") &"', ' "& request.Form("event_duration") &" ', ' "& request.Form("cle_credit") &" ', ' "& request.Form("video") &" ', ' "& request.Form("add_comments") &"')"
ELSE
if request.form("location") = "FTM" Then
SQL = "insert into FTM (manager, program_title, event_date, event_time, event_duration, cle_credit, video, add_comments) values ('"& request.Form("manager") &"', ' "& request.Form("program_title") &" ', ' "& request.Form("event_date") &" ', ' "& request.Form("event_time") &"', ' "& request.Form("event_duration") &" ', ' "& request.Form("cle_credit") &" ', ' "& request.Form("video") &" ', ' "& request.Form("add_comments") &"')"
ELSE

conn.execute(SQL)

end if
end if
end if
end if
next
response.redirect "thankyou.asp" 
%>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros