Solved

Option Explicit

Posted on 2012-03-12
3
474 Views
Last Modified: 2012-06-21
Dear Experts,

I have recently run the performance analyser over the forms in my Access 2010 database and it suggested I add an option Explicit Statement to one of the forms.  However in doing so it breaks one piece of code, I believe I need to declare all the variables, but I'm not sure how to do this on this piece of code:

Private Sub UpdateRecipients_Click()
Me.Recipients = ""
RecipientsList.BoundColumn = 3
For Each Item In RecipientsList.ItemsSelected
    Recipients = Recipients + RecipientsList.ItemData(Item) + "; "
Next Item

Me.RecipientsVisual = ""
RecipientsList.BoundColumn = 2
For Each Item In RecipientsList.ItemsSelected
    Me.RecipientsVisual = Me.RecipientsVisual + RecipientsList.ItemData(Item) + ", "
Next Item
End Sub

Open in new window


Can anybody help?
0
Comment
Question by:correlate
[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
3 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 37709037
Add
Dim Item as Variant at the beginning


Kelvin
0
 

Expert Comment

by:weegiraffe
ID: 37709040
Option Explicit forces the programmer to declare all variables which is good programming practice.

If using it breaks the code, it is because you have one or more undeclared variables.  Access should show you your undeclared variables when you execute the code.
0
 

Author Closing Comment

by:correlate
ID: 37709045
brilliant - Thank you very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…

733 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