?
Solved

Option Explicit

Posted on 2012-03-12
3
Medium Priority
?
481 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 2000 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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 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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

752 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