How to write a simple code using Microsoft Access

Microsoft Access

Microsoft Access is a relational database management system (RDBMS), and one of the examples of application software that helps many users and individuals to create and manage databases.

Functions of Access

The Ms. Access can be used to perform the following, namely: create tables, queries, forms, reports, and macros. Macros are small programs that can be used to automate tasks in Access.

To write a simple code using Microsoft Access, you can use the Macro Builder. The Macro Builder is a tool that allows you to create and edit macros. To open the Macro Builder, click the “Macro” button on the Home tab.

Once you have opened the Macro Builder, you can create a new macro by clicking the “New” button. You can then enter the code for your macro in the Code window.

The following is an example of a simple code that you can use to create a new record in a table:


Sub CreateNewRecord()

Dim tblCustomers As TableDef
Dim txtFirstName As String
Dim txtLastName As String
Dim txtEmail As String

Get the Customers table.
tblCustomers = CurrentDb.TableDefs(“Customers”)

‘ Make or genrate/create  a new record in the Customers table.
txtFirstName = InputBox(“Enter the first name.”)
txtLastName = InputBox(“Enter the last name.”)
txtEmail = InputBox(“Enter the email address.”)

tblCustomers.AddNew
tblCustomers!FirstName = txtFirstName
tblCustomers!LastName = txtLastName
tblCustomers!Email = txtEmail

tblCustomers.Update

End Sub

This code will create a new record in the Customers table with the first name, last name, and email address that you entered.

Related posts:

About Author


Discover more from SURFCLOUD TECHNOLOGY

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from SURFCLOUD TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading