SQL- Insert Into Statement
The SQL INSERT INTO Statement is the SQL code that used to insert a new data into table in database.
SQL INSERT INTO Syntax
INSERT INTO table_name (fieldName1, fieldName2, fieldName3,…) VALUES(value_for_fieldName1, value_for_fieldName2, value_for_fieldName3,…);
SQL INSERT INTO Example
The Insert Into command can be put under the click button to add new records into a table. For example below, add a new customer name, Address, City, State from Unbound text boxes on blank form to the tbl_Customer table.
Set four Unbound text boxes as following:
- txtName for Customer Name field
- txtAddress for Address field
- txtCity for City field
- txtState for State field
VB Code under Save Customer button:
If click on Save Customer button without entering any data, a message box “There is no data to save” will pop up as shown below.
After entering the customer information and click Save Customer button, the data will be saved into table tbl_Customer with a message of saving successfully.
After click on the OK button on the message box, all text boxes will be set to blank and ready to add another customer.