Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Memo field and data filtering

We design tables carefully to organize information properly so that we can retrieve them easily through search, filter etc.  If you look at the Employees table in the Northwind.mdb sample database you can see that even an employee's name is split into three parts (Title, First Name & Last Name) and stored into three different fields so that we can work with each piece of information separately.  The name fields are defined to a specific length taking into consideration of the size of the source information.

When it comes to recording of employees' qualifications or work experience we cannot define the field size to a specific length because the length of information may vary from case to case.  This is where we think of the Memo field type.  Memo field is a free form text field where you can record descriptive information of various lengths.

When we want to extract information for reports or views we never think of using the Memo field contents because it has information in an unpredictable form and considered difficult to work with besides displaying/printing it's contents.

Even though Memo Field has only limited flexibility in data filter operations, we can filter records based on specific text spread all over different locations in the memo field.

We can try few examples with Memo Field data from the Employees Table of Northwind.mdb sample database.

  1. Import the Employees Table from the sample database C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb.
  2. Open the Employees Table in datasheet view.
  3. Move the horizontal scrollbar at the bottom to the right so that the Notes Memo Field contents are visible to you.
  4. Point the mouse at the left border of the table at the inter-section of the two rows so that the mouse pointer turns into a cross.
  5. Click and drag down to increase the row size bigger so that the Notes field contents can be viewed properly.

    Now, if you look at the qualification information of each employee record you can see that most of them have a BA degree but the text "BA" is not positioned at a specific location in the Memo Field. If you want to filter all employees records with BA degree, how do we do it?

    Let us do it directly on the datasheet view first, before we consider writing a Query to filter data based on text in the Memo Field.

  6. Highlight the letters BA in any one of the records and Right-click on the highlighted text.

    A shortcut menu is displayed and the suggested options are for filtering data from the Memo Field are Contains "BA" or Does Not Contain "BA".

  7. Click on the Contains "BA" option to filter the records with the text "BA" appearing anywhere within the memo field.

If you want to filter records this way for printing a Report then we must create Queries to filter data based on text in Memo Field.  You can use the Like Operator combined with AND, OR logical operators.

Copy and the paste the following SQL Strings into the SQL Editing Window of new Queries and save them with the suggested names:

Query Name:  Employee_BAQ

SELECT Employees.LastName, Employees.FirstName, Employees.Notes
FROM Employees
WHERE (((Employees.Notes) Like "*BA*"));

The output of this Query will include a record of an employee with MBA Degree too, because the text 'BA' in MBA. If you want exclude this record then modify the criteria with a space immediately after the first asterisk like '* BA*'.

Query Name:   Employee_BA_BSCQ

SELECT Employees.LastName, Employees.FirstName, Employees.Notes
FROM Employees
WHERE (((Employees.Notes) Like "* BA*")) OR (((Employees.Notes) Like "*BSC*"));

The above query gives the example of the usage of the logical operator OR to filter data of employees with graduation in BA or BSC.

Query Name:   Employee_BA_BSCQ

SELECT Employees.LastName, Employees.FirstName, Employees.Notes
FROM Employees
WHERE (((Employees.Notes) Like "* BA*" And (Employees.Notes) Like "*psychology*"));

The above example shows the usage of the logical operator AND and filters the records of the employees with graduation in BA in Psychology.

Share:

No comments:

Post a Comment

Translate



PageRank
Your email address:

Delivered by FeedBurner

Search

Infolinks Text Ads


Blogs Directory

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

Forms How Tos Functions MS-Access Security Reports Animations msaccess animation msaccess forms Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Queries External Links msaccess reports msaccess tips Menus and Toolbars Accesstips MsaccessLinks Process Controls Art Work Downloads msaccess How Tos Graph Charts msaccessQuery List Boxes Command Buttons Emails and Alerts Query Combo Boxes Custom Wizards ms-access functions msaccess graphs msaccess reporttricks msaccessprocess security advanced Access Security DOS Commands Data Macros Menus Property Report Top Values VBA msaccess email msaccess menus progressmeter Access2007 Array Auto-Number Command Button Custom Functions Join Microsoft Numbering System Records Security Split SubForm Table Utility Workgroup database msaccess functions msaccess wizards Access2003 Accounting Year Action Animation Attachment Binary Numbers Budgeting Calculation ChDir Color Palette Conditional Formatting Controls Copy Data Filtering Data Type Defining Pages Diagram Disk Dynamic Lookup Error Handler Excel Export Expression External Field Type Fields Filter Form Form Instances Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Methods Monitoring Object Reference Objects Octal Numbers Operating System Paste Primary-Key Product Rank Reading Rich Text Sequence SetFocus Summary Tab-Page Time Difference Union Query User Users Variables Water-Mark Word automatically commands function hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar tutorial updating upload vba code

Featured Post

DIR Getting File Names From Folder

We all know Dir() Function from the time of Windows DOS Operating System.  This is the first Command introduced to those who sit on a Perso...

Labels

Blog Archive

Recent Posts