MS Access Contact List

Contact List

MS Access Contact List might not be better than the original Microsoft Access imported Database. However, it has the simplicity and almost most of the features that the imported Contact Management Database has. The main purpose of MS Access Contact List is to learn more VBA codes and how they were joined together to form this program.

MS Access Contact List consists of the following:

  1. Add New Record
  2. The feature of Search As You Type
  3. Loop through all records in MS Access within a table to edit and update records
  4. Use the SetOrderBy method to apply a sort to the active form
  5. Sending an email through Outlook
  6. The use of Form.Filter property
  7. Other VBA Codes such as MsgBox, InputBox, Delete Records, etc.

Syntax of Add New Record

				
					DoCmd.GoToRecord , , acNewRec
				
			

The feature of Search As You Type

There is a separate post on this feature, please visit this post here.

Looping through all records in MS Access within a table to edit and update records

After setting the current database, use the below VBA code: 

				
					If Not (rs.EOF And rs.BOF) Then
    rs.MoveFirst
    Do Until rs.EOF = True
        rs.Edit
        rs!ContactID = [SomeValue]
        rs.Update
        rs.MoveNext
    Loop
Else
    MsgBox "There are no records in the recordset."
End If
rs.Close
Set rs = Nothing
				
			

Syntax of the SetOrderBy method to apply a sort to the active form

				
					DoCmd.SetOrderBy "FieldName"
				
			

Syntax of sending an email through Outlook

				
					Dim oEmailItem As MailItem
  On Error Resume Next
  Set oOutlook = GetObject(, "Outlook.Application")
  If oOutlook Is Nothing Then Set oOutlook = CreateObject("Outlook.Application")
  Set oEmailItem = oOutlook.CreateItem(olMailItem)
  With oEmailItem
   .To = emailaddress.Value
   .Display
  End With
  Set oEmailItem = Nothing
  Set oOutlook = Nothing
				
			

Syntax of Form.Filter property

				
					Me.Filter = "[FieldName] Like '*" & [ControlName] & "*'"
Me.FilterOn = True
				
			

Syntax of Message Box

				
					If MsgBox("Exit Program?", vbYesNo, "Quit") = vbYes Then DoCmd.Quit
				
			

Syntax of Input Box

				
					Dim strInput As String
strInput = InputBox("Contact Name:", "Search for Contact Name")
				
			

For more pro MS Access Programs, please visit our home page here.