Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Memo field and data filtering

Introduction.

When designing tables, we carefully organize information to make it easy to retrieve through searches, filters, and queries. For example, in the Employees table of the Northwind.mdb sample database, an employee’s name is split into three separate fields—Title, FirstName, and LastName—so that each piece of information can be managed individually. These fields are also defined with specific lengths, based on the size of the source data.

However, when recording details such as an employee’s qualifications or work experience, we cannot predict the length of the text. In such cases, the Memo field type is used. A memo field allows free-form text of varying lengths, making it ideal for storing descriptive information.

That said, memo fields are not often used directly in reports or queries because their contents are unstructured and more difficult to work with. Still, they do provide some flexibility in filtering records—for example, by searching for specific text that may appear anywhere within the field.

Let’s look at a few examples of working with memo field data from the Employees table in the Northwind.mdb sample database.

Prepare for a Trial Run.

  1. Import the Employees Table from the sample database C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb.

  2. Open the Employees Table in the 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 intersection of the two rows so that the mouse pointer turns into a cross.

  5. Click and drag down to increase the row size so that the Notes field contents can be viewed properly.

    If you review the qualification details stored in each employee record, you’ll notice that many employees hold a BA degree. However, the text “BA” does not appear in a fixed position within the memo field—it may occur anywhere in the description. So how can we filter all employee records that include a BA degree?

    To begin, let’s try this directly in Datasheet View before moving on to writing a query that filters data based on text within a 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 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 the text in the Memo Field.  You can use the Like Operator with AND, OR logical operators.

Copy and 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 an MBA Degree, too, because of the text 'BA' in MBA. If you want to 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 is an example of the usage of the logical operator OR to filter data of employees with a 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 demonstrates the logical operator AND, and filters the records of the employees with a graduation in BA in Psychology.

Earlier Post Link References:

Share:

No comments:

Post a Comment

Comments subject to moderation before publishing.

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

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