How to Build an Insert Query in Access Database

Save

Microsoft Access provides users with a small, lightweight database application that can be used in web or desktop software. Microsoft Access also allows users to run reports and monitor business finances using tables and stored procedures. All the information created in Access is stored in tables. An "insert" query is the main function that inserts a new record into these tables. Microsoft Access has a code console that allows you to create the insert queries.

  • Open Microsoft Access and click on the "Query" icon at the main menu. This displays a window that lists all your currently programmed queries in Microsoft Access.

  • Click the "New Query" button. The design view opens and a list of tables included in the database is displayed. Click the "Cancel" button. In the main menu, click the "SQL Code" view. This switches from the main design viewer to the code console, which is used to create insert queries in SQL.

  • Type the following insert query shell into the code window:
    insert into <table>
    (column1, column2, column3)
    values
    ([val1],[val2],[val3])
    Replace "<table>" with the table name where the data is inserted. The second line is the table's columns. These columns represent the column names given when you designed the table. Finally, the last line represents the values. In this example, the values are surrounded in brackets. The brackets indicate to Microsoft Access that the user is prompted for the information.

  • Click the "Save" button at the top of the Access window. Enter a name for the new query in the prompt, and close the SQL Viewer. The main query window is displayed again, and the new query is now listed.

  • Double-click the new query to test it's function. Before inserting values, a prompt is displayed for you to enter the data. Enter it and press the "OK" button. The values you enter are inserted into the Access table.

References

  • Photo Credit laptop with database record on 15.4" wide screen image by .shock from Fotolia.com
Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!