Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-03-29
2
Medium Priority
?
358 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 500 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 500 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

971 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