Solved

When to use Option Compare Database versus Option Explicit in an Access Form?

Posted on 2009-03-29
2
334 Views
Last Modified: 2013-11-28
How does one determine whether to use Option Compare Database versus or in conjunction with Option Explicit in an Access Form?  When I run analyze performance it tells me to use Option Explicit in my form.  I don't know if this should replace Option Compare Database or be added beneath it.  The code is below
Option Compare Database
 
Private Sub Run_Click()
    Me.Requery
End Sub

Open in new window

0
Comment
Question by:kgittinger
2 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 24014738
You want to use both.  Option Explicit means that you must declare a variable first before you can use it.  This helps minimize compile errors down the road ... and prevents confusion wherein you might use the same variable name twice when you did not intend to.

mx
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 125 total points
ID: 24014744
Add it beneath.  It means you will get an error if you use an undeclared variable.  Without it , any variables used that are not declared with a Dim statement are created as Variants, with all the incumbent overhead.,
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question