Solved

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

Posted on 2009-03-29
2
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

626 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