updating tables with a form

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

Guest

I have an unbound form with 2 text boxes the user enters info in. I want
them to push a button next and have the the info added as a new record in a
table.

Is this possible? Any help getting started would be greatly appreciated.
Thanks.
 
JT said:
I have an unbound form with 2 text boxes the user enters info in. I
want them to push a button next and have the the info added as a new
record in a table.

Is this possible? Any help getting started would be greatly
appreciated. Thanks.

Code in the Click event of your CommandButton would execute an APPEND query
using the values in the TextBoxes in the VALUES list.

CurrentDB.Execute "INSERT INTO TableName (NumericFieldName, TextFieldName,
DateFieldName) VALUES(" & Me.NumericControlName & ", '" & Me.TextControlName
& "', #" & Me.DateControlName & "#)", dbFailOnError

Example uses three fields and controls to show an example of the proper
delimiting for a number, text, and date respectively. In my example if I
entered the number 123, the text "Some Text", and today's date the SQL
string would evaluate to...

INSERT INTO TableName (NumericFieldName, TextFieldName, DateFieldName)
VALUES(123, 'Some Text', #8/22/2005#)
 
Back
Top