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!

Append Query Using textbox's text?

Status
Not open for further replies.

adamr99

Programmer
Jun 25, 2001
59
0
0
US
How do I insert records into a table using an append query with one of the feilds of the table being populated with the contents of a form's text box?

I am using a cmd button to run the query - IE, the user clicks on "Update" and the stuff that they typed into the textbox gets updated.

Thanks
Adam
 
Hello Adam,
Here is some [untested] code that should do the trick:
Code:
Private Sub Update_Click()
CurrentProject.Connection.Execute "INSERT INTO MyTable (MyField) VALUES ('" & MyTextbox & "')"
End Sub
Just substitute the appropriate values. One thing to note is: if your text box will ever contain the ' character this will cause a problem. The solution would be to either parse the text box value before appending it above, or use an ADO Recordset to append the record instead, or use the ADO command object w/ an ADO Parameter object.
Good Luck, Robert
•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•
Professional, affordable, Access database solutions and assistance °•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°•°
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top