Solved

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

Posted on 2009-03-29
2
329 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 - Access MVP) 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Normalization of a table 19 75
How to Comment Out Lines of Code in a Pass Through Query In MS Access 2016 19 54
Access Update Query 1 20
Should I keep recordsets open? 3 24
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

810 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