inserting new record in database
-
I am attempting to add a new record to a database (in this case Access) I have created a VB form with a textbox (txtName) to enter a new name and a command button to update the recordset by running a SQL statement by using an Insert Into command. The Insert Into statement requires a "values" parameter. I am trying to take the txtName.Text property and place it into the Values parameter. But it does not want to work this simply. Any input is welcome. thanks Craig
-
I am attempting to add a new record to a database (in this case Access) I have created a VB form with a textbox (txtName) to enter a new name and a command button to update the recordset by running a SQL statement by using an Insert Into command. The Insert Into statement requires a "values" parameter. I am trying to take the txtName.Text property and place it into the Values parameter. But it does not want to work this simply. Any input is welcome. thanks Craig
Your code could look something like that (providing you are using ADO): MyConnection.Open MyConnectionString MySQL = "INSERT INTO MyTable(MyField) VALUES('" & _ txtName.Text & "')" MyConnection.Execute MySQL MyConnection.Close I hope this helps.