Home  Fees/Services  Access 2010 Template  Access Tutorial  Access Download  Articles  Search  Contact  Privacy  Links

Global Variables in VBA as Query Parameters






Open Email Using SendObject Access Download

User Inactivity Logout VBA Code

Disable Shift Key Demo

Send Email Microsoft Access Tutorial Download (Advanced)

Sequential Counter in Query

Multi Select List Box Query Parameters

Row Level Data Security

Programming MS Access Security Alternative

Single User Inventory Calculations Download

How To Perform Multi-User Inventory Calculations

Make Dependent Combo Box Code MS Access Tutorial

Union Query Example (Simple)

Union Query (Advanced) Access Tutorial

How To Fill Fields From Combo Box

Use Global Variables as Parameters

Continuous Form Dependent Combo Box

How To Program Continuous-Continuous Master/Detail Forms

Access Bar Chart / Bar Graph

Programming Crosstab Query Example

TransferText & OutputTo Microsoft Access

DoCmd.OpenForm & OpenArgs VBA Example

Running Sum Query Method

Choose Command Dynamic SQL Order By

Access Conditional Format

Access Report Banding

Popup Form Control Method


Visual Basic Global Variables as Query Parameters



Our programming team has 15 members containing a wide variety of technical database knowledge and programming experience. We are kind of like Allstate Insurance - 'we have seen it before'.

We create databases large and small. Some of our databases help run entire small businesses including travel agencies and airline reservation systems. We also handle unique businesses such as fly rod manufacturing. Did you know there are 11 steps in the making of a fly rod?


Using global variables to pass user selection criteria to queries is a useful programming technique to master.

This Access download will provide you with all the forms, modules, queries and VBA code to get you started. Here is the SQL query code used in the example: SELECT M_Student_Courses.Student_ID, L_Students.Student, L_Courses.Course
FROM (M_Student_Courses INNER JOIN L_Students ON M_Student_Courses.Student_ID = L_Students.Student_ID) INNER JOIN L_Courses ON M_Student_Courses.Course_ID = L_Courses.Course_ID
WHERE (((M_Student_Courses.Student_ID)=get_global('gbl_student_id')))
ORDER BY L_Students.Student, L_Courses.Course;

In the code above, get_global is a custom query function that passes back the value of any global variable you have defined.  In this case we are retrieving the GBL_Student_ID which was previously selected as a parameter in the form below.

Note that you can create and use custom VBA functions in queries just as you use custom public functions in regular VBA code.  These custom function can perform complex recordset operations that are not normally available in access queries.  Complex scalar functions can be implemented with simple VBA custom functions.  The get_global function is just a simple example of these query functions. There are other methods for returning global variables, such as the Eval function, however we find this custom method more reliable and flexible.

Give our Global Variables as Query Parameters downloadable Access example a try.
 

Download Global Variable Access

See the following additional in-site resources for global variables:

VBA Global Variables

Using Access Visual Basic global variables programming Microsoft Access - VB script code help, samples.

Visual Basic Global Variables as Query Parameters
In the code above, get_global is a custom query function that passes back the value of any global variable you have defined. In this case we are retrieving...









A Blue Claw Software Design Template:

Loan Process Management Access Database
 










A Blue Claw Database Design Article:

Microsoft Access On The Internet
 









Blue Claw Database Design Downloadable Tutorial:
Union Query (Advanced) Access Tutorial Download  









Here is a randomly selected programming tutorial:

DoCmd ApplyFilter
 


Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013
Access 2016
Updated On 2/11/2017 5:20:51 AM

Contact Information

Copyright 2000-2017 Blue Claw Database Design

MS Access 2013, Access 2010 & Microsoft Office 2007