ArticlesBase.com - Free Articles Directory
Free Online Articles Directory
16.10.2008 Sign In Register Hello Guest
Email:
Password:
Remember Me 
forgot your password?


Ms Access Tip – How to Use Variables in the Access Query Design Form

Author: Jon Watson Author Ranking Blue | Posted: 26-12-2007 | Comments: 0 | Views: 56 | Rating:  (52) Article Popularity - Blue (?) Got a Question? Ask.
Sign Up Now!

MS Access Tip – How to use variables in the Access query design form.

In this example you are going to learn how to enter or select data in one form and open another form with more data related to the field you just selected by taking advantage of global variables in the query design form. To help achieve this, you will use a global variable entered in the criteria of a field while creating the query in the Access query design form. The result is a powerful user interface function that allows a user to look up more data, or enter more data related to a selected record. Users can use it to look up pricing histories, addresses, inventory locations, really anything where you would have more data about a key field in your database.

You can achieve this by learning to use global variables. These variables can be accessed by any form, query, macro, or other modules while you are in the Access session. Use a module to store these variables in.

There are several simple steps to achieve this functionality.
Create a global variable in a module
Create your data table.
Create the source query for the “look up” or pop up form
Create the pop up form with the source query as the data source
Create the form to enter the selection from and enter the VBA code to the pertinent control events on the form to open the look up form.

1) Create a module with the following few lines of code.

Option Compare Database
Public DFname As String

Public Function GetVFname () As String
GetVFname = VFname
End Function

2) Create a table with the following fields for demonstration sake. ID as an autonumber. Then create Fname, Lname , Street, City, St, Zip, County, Phone as text fields and lastly add DOB as a date field.

Set the form to be a pop up form. While in design mode, make sure the form is selected and then on the “Other” tab turn the Pop Up setting to yes. Save the table naming it Client.

3) Next create a query to use as the data source for your form. Use the Client table as the source and select all the fields from the table field list using the Windows shift select feature and drag them down to the field view portion of the Query by Example form. Now in the ID field, set the Criteria as:
GetVFname ()
Close the query and save it as IDQry

4) Create a form using the query you just created as the data source. So, on the Data tab on the form select IDQry. Just put all the fields on the form for this example. Save it as ClientData.

5) Create a second form and use the client table as the data source. This form is used to demonstrate selecting a record with a double click event and getting the pop up form with more information related to the selected record.

In a real application you may want to access data from other tables/forms in the same way. Pull in the Id, Fname and Lname fields only. Close and save the form as NameLst.
Put the following code on the double click event of the Id field. This will open the “ClientData” form with the selected Client.

Private Sub ID_DblClick(Cancel As Integer)
VFname = Me.ID.Value
DoCmd.OpenForm “ClientData”, acNormal
End Sub

Now to see this example work, simply open the NameLst form and double click on the ID field in any record.

This example was created with Access 2002. There are more than likely many different ways to accomplish the same functionality, but we have found that this general approach is the most scalable to larger applications.

Rate this Article: Current: 0 / 5 stars - 0 vote(s).

Article Source: http://www.articlesbase.com/management-articles/ms-access-tip-how-to-use-variables-in-the-access-query-design-form-290713.html

Print this Article Print article   Email to a Friend Send to friend   Publish this Article on your Website Publish this Article   Send Author Feedback Author feedback  
About the Author:

Jon Watson is the founder of Biomation Systems, Inc. With 26 years experience helping Fortune 500 companies with process improvement he formed BioMation to bring the same expertise to smaller companies that need the same improvements at an affordable price.
You can find more help for MS Access at:
www.biomationsystems.com
www.accessdatabasehelp.com
www.accesshelpebook.com

Submitting articles has become one of the most popular means of generating quality backlinks and targeted traffic to your website. Join us today - It's Free!

Article Comments

Comment on this article Comment on this article
Your Name
Your Email:
Comment Body
Enter Validation Code: Captcha


Related Articles

Ms Access Tutorial - How to Use Color Coding to Enhance your Applications
By: Jon Watson | 18/12/2007 | Management
Color coding adds value to a form as it easily directs the user's eye to critical data. This is a powerful technique that allows a user to quickly evaluate a pages of data for errors or warning information.

How to Get the Most From your Training Dollar
By: Jon Watson | 12/12/2007 | Management
There are so many people telling you that you can make such a huge return on your investment these days that you just can't believe any of them any longer. I know, I have received so many get rich emails that I should be earning about a billion a day now! How about investing in something that you really believe in. Yourself.

Ms Access Tip – you Have Heard ofs, Now Learn to Use Them
By: Jon Watson | 11/01/2008 | Management
This example demonstrates using an array and SQL statements to create the similar records. It also has a function to replace records if you want to change the amount value and update the data table. The replace function assumes that the description and date are the same and replaces every occurrence of the existing record with the latest amount value. For safekeeping the replace function makes a copy of the data table before executing.

Ms Access And Ms Excel - What To Do When Sorting Does Not Work
By: Richard Killey | 24/04/2007 | Computers
In both Microsoft Access and Microsoft Excel it is very easy to sort columns of text or numbers. Both programs supply us with toolbar buttons that allow either ascending sorts (1 ... 999) or descending sorts (999 ... 1). The Ascending button has a blue "A" above a red "Z"...

Accessing Ms Access Using Java
By: Twinkle | 20/12/2007 | Programming
JDBC connection using JAVA code

Using Your it to Excel in Tough Times
By: Robin George | 24/09/2008 | Databases
Find out how to beat the current difficult financial climate, using the software on your computer.

Migrating From Microsoft Access to Mysql
By: Intelligent Converters | 16/06/2008 | Databases
This article discovers common techniques of migrating MS Access data to MySQL server and possible issues during the conversion process.

Got a Question? Ask.

Ask the community a question about this article:

Q&A Powered by:
Powered by Yedda 

Latest Management Articles

Improve Employee Performance by Letting Aspiring Leaders Take Charge
By: Barbara Brown, PhD | 16/10/2008
If you have an employee who always wants to lead assignments, encourage better performance by finding ways to let him or her have a leadership role. This article explains how you can use this strategy to improve employee performance and gives you three situations that offer leadership responsibilities.

Diversity Management
By: Janine Sergay | 16/10/2008
Opportunity for all Is it not every individual's right to be afforded opportunities to put forward their best efforts? To develop their potential? And to show their worth through the results they produce? Not only is this a moral and ethical imperative but, within many countries, a legal one too. Simple statistics...

Inventory Management System for Proper Demand and Supply
By: spinxwebdesign | 16/10/2008
Inventory management system is being popularly used by many companies and organization worldwide.

Executive Coaching India : How Does Coaching Work?
By: Vaishally Nath | 14/10/2008
Executive Coaching India www.executivecoachingindia.com The Orange Academy (www.executivecoachingindia.com) is one of the front runners of coaching in India. The organization has in its fold world class coaches with sizeable experience and insights at the leadership levels. Their expertise gives The Orange Academy an edge to provide the best of coaching results. This article outlines the coaching process and answes some frequently asked questions by the users consumers of coaching services.

Six Sigma Green Belt Certification
By: Robert | 14/10/2008
six sigma green belt certification as an employee can increase your effectiveness as an employee and save you thousands or millions of dollars as a business owner.

Tips on Looking for a Good Venture Capital Business Firm
By: Trisha Rich | 14/10/2008
Numerous ventures are experienced with the challenging task of increasing thier venture capital. If you are one them, then this process might be helpful on finding the right venture capital firm for your business. Although this may look easy.

Improve Employee Performance by Letting "talkers" Speak
By: Barbara Brown, PhD | 14/10/2008
If you have employees who love to talk, consider using their passion for talking as a way to encourage greater cooperation and contributions. This article explains the usefulness of this approach and gives you four situations where you might apply it.

Payroll Frequency: the Difference and the Cost Savings
By: Rebecca Beckett | 14/10/2008
It is essential that companies consider payroll frequency when looking for a way to cut costs. Choosing the frequency best for your company will make for a smooth process.

More from Jon Watson

Ms Access Tip – you Have Heard ofs, Now Learn to Use Them
By: Jon Watson | 11/01/2008 | Management
This example demonstrates using an array and SQL statements to create the similar records. It also has a function to replace records if you want to change the amount value and update the data table. The replace function assumes that the description and date are the same and replaces every occurrence of the existing record with the latest amount value. For safekeeping the replace function makes a copy of the data table before executing.

Ms Access Tutorial - How to Use Color Coding to Enhance your Applications
By: Jon Watson | 18/12/2007 | Management
Color coding adds value to a form as it easily directs the user's eye to critical data. This is a powerful technique that allows a user to quickly evaluate a pages of data for errors or warning information.

How to Get the Most From your Training Dollar
By: Jon Watson | 12/12/2007 | Management
There are so many people telling you that you can make such a huge return on your investment these days that you just can't believe any of them any longer. I know, I have received so many get rich emails that I should be earning about a billion a day now! How about investing in something that you really believe in. Yourself.

Ms Access Tip: Self Learning Combo Box
By: Jon Watson | 12/11/2007 | Technology
Database data entry can be tedious at times. You can make your databases more user friendly if they have a way to select data to enter rather than typing in the same data over and over. Access provides a form control called a combo box to help with this task but it can lead to trouble.

Access Databasetip: Create a User Defined Search Field for a List Box
By: Jon Watson | 02/11/2007 | Technology
Many times it is necessary to provide your users with an easy way to filter or search for data in large table of information. This tip will show you one quick and easy way to solve the problem by giving the user a field to enter a search string and updating the form with those fields that fit the search pattern. It's quick and easy, so give it a try. Read about how Access was a big success solving a license tracking issue in this article.

Access Database Tip: How to Multiselect in a Listbox
By: Jon Watson | 26/10/2007 | Technology
When you have a list box it is handy to be able to multiselect to perform some action on multiple items in the listbox. Here is a simple set of instructions to get you started. These instructions will create a quick way to multiselect and delete rows from a table.

Ms Access Tip: Keeping Up With User Activity
By: Jon Watson | 25/10/2007 | Technology
At times you will find it very handy to know what a user was doing in your application at a specific time. This is especially useful with multi-user database applications for debugging or security reasons. With this tool implemented in your applications you will be able to see what event happened and at what time.

Improve your Access Applications in Minutes
By: Jon Watson | 23/10/2007 | Databases
This article details how to create a very powerful tool that can be used in any Access database that gives your users the abililty to drill down through complex data reationships and find exactly what they are looking for in just a few mouse clicks..

Article Categories






Give Feedback

Sign up for our email newsletter

Receive updates, enter your email below