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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to create new records on a table based on form

Status
Not open for further replies.

mdgarred

MIS
Mar 29, 2007
1
0
0
US
Hi!
I have been looking all over and haven't been able to find a solution to my problem. I wonder if I'm not doing things the right way.
I have a questionnaire. There is a table with questions ID's and questions and a dropdown menu with the different answers. There are also two boxes with the Date and hospital ID (these two parameters were picked on a previous form and were passed to my new form).
The form navigates through the questions and I would like to insert a record on another table (answer table) everytime the question changes.
I have tried with subforms and it hasn't worked. I have also tried with an SQL Statement but it's giving me errors. I am copying the statement below. If you think that there is a better option to accomplish this that would be greatly appreciated too..
thanks in advance!!!
SQL = "INSERT INTO answers ( CliniqID, Date, VarID, AnswerOther) VALUES ("&DQ&Text18&DQ&","&DQ&Text16&DQ&","&DQ&VarID&DQ&","&DQ&Combo8&DQ&","&DQ&Text14&DQ&");"
DoCmd.RunSQL SQL
 
mdgarred,

Why add all the double quotes to the concatenation?

Ken S.
 
Assuming Text18, Text16, etc. are all string values, and are all on the current form:
Code:
SQL = "INSERT INTO answers ( CliniqID, Date, VarID, AnswerOther) " _
& "VALUES ('" & Me.Text18 & "','" & Me.Text16 & "','" & Me.VarID & "','" _
& Me.Combo8 & "','" & Me.Text14 & "');"
HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top