-
I'm just looking over your project. This is where different coding styles come into play. I know Greg prefers everything left-justified (to start), so that Dimmed variables are at the same indent level as Private Sub, etc.
And I prefer everything to start at one indent level inside of the Sub and End Sub lines (except for labels, which are always left-justified).
However, despite coding "style" differences, Greg and I would both agree: you really really need to indent your code properly. You should be able to visually see the logic of your macro.
If yadayada Then
Else
If yadayadayada Then
Else
End If
End If
Is very very difficult to read.
[vba]
If yadayada Then
Else
If yadayadayada Then
Else
End If
End If
[/vba]
Is much easier to read. This will also help you to diagnose problems. Any time you see an End If directly above another (with no indenting), you may very well have a mistake in your code. Or, at the very least, it will be harder to troubleshoot that code later.
Now, before you get irritated that I've spent so much time not giving you the answer...
Two theoretical issues with your code:
1. You have what I would call a "primary" logical construct in this OnExit routine: the .Tag property of the ContentControl you are exiting. And yet, you test it in two different ways (a select case, and then later in an if statement). You have fallen into a fairly common trap: a TYPO. In one place you test for "voteauth" and set a value, and then later check that value, but only if the same test equals "voteauthin"
Rather than fixing the problem, I'm trying to help you see why, conceptually, you should re-structure and *understand* rather than just "fix it." Because you'll avoid this problem in the future.
2. You don't comment your code at all. Comments aren't just for ignoring pieces of code, they are for explaining what all this mumbo jumbo means. Especially when soliciting help.
While I was writing this, you then indicated that the "voteauth"/"voteauthin" issue isn't a typo, that is an indication of your desire to reference a totally different control. Comments would help explain that desire.
Comments are also extremely helpful when you come back to the code 6 months later and don't remember what was supposed to happen (i.e., you might not remember the voteauth/voteauthin issue, and simply think it's a typo like I did).
So, now we know the problem:
1. You want to reference a DIFFERENT content control during the OnExit event of a content control. Got it. Give me a second. This is the kind of help that experience makes easier.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules