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

blog.feedspot.com Microsoft Access Blogs

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

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

Base Class and Derived Object Variants

Last week we have tried an example as how to pass a Base Class Object, through the Set Property Procedure,  to become part of the Object in...

Labels

Blog Archive

Recent Posts