Solved

Option Explicit

Posted on 2012-03-12
3
461 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
3 Comments
 
LVL 22

Accepted Solution

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


Kelvin
0
 

Expert Comment

by:weegiraffe
Comment Utility
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
Comment Utility
brilliant - Thank you very much
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now