Link to home
Start Free TrialLog in
Avatar of Tom Crowfoot
Tom CrowfootFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Option Explicit

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?
ASKER CERTIFIED SOLUTION
Avatar of Kelvin Sparks
Kelvin Sparks
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of Tom Crowfoot

ASKER

brilliant - Thank you very much