Save Record from Form to another table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a combo box that is based on a table of premade
'comments'. If a user has another 'comment' to add that is not on the list. I
want them to be able to add it to the table. How can I have them just check a
box that will copy the contents of the text box into a new record in the
comment table?
 
On the onclick event of a button to add the value to the other table, run an
insert query

Docmd.RunSql "INSERT INTO MycommentTable ( Comment) VALUES ('" &
me.CommentFieldNameInForm & "')"
 
AWESOME! let me try and understand what you wrote- when you say ( Comment)...
is that what the user has written? or what?

what I have so far is...
Docmd.RunSql "INSERT INTO Comments ( Comment) VALUES ('" &
me.Comments & "')"

Am I close? because both the table and comment field name are called
"comments".
 
The Me stand for the current form, so Me.Comment stand for the name of the
field in the form, and that will return the value in the text box.
In the Sql, you join the value from the form to the sql string, so when it
runs it will look like
"INSERT INTO Comments ( Comment) VALUES ('My Coment String')"

So the value 'My Coment String' will be inserted in the comments table
======================================
Docmd.RunSql "INSERT INTO Comments ( Comment) VALUES ('" & me.Comments & "')"
That should wotk if the button you click and the text box are on the same
form.
 
thank you thank you thank you!!
It didn't work with the & and ' marks, but once I took them out it all
worked out according to plan. You're awesome!
 
Any time :-)

The Mecca said:
thank you thank you thank you!!
It didn't work with the & and ' marks, but once I took them out it all
worked out according to plan. You're awesome!
 
Back
Top