In the attached Access 2003 database, I created a Form and then added four labels. I added a button and when the button is clicked the code cycles through the labels with a For Each statement (see code below). The problem is that when I add another label, a new label, the label is not recognized when the code is cycling through the labels. The new label has a little error message flag saying that the label is not associated with a control, I'm not sure if that matters or not. I tried turning off the error checking for unassociated labels and it didn't fix the problem.
When the code gets to the new label it gives the error message "run time error 13 type mismatch". If I click on Debug and continue stepping through the code, the code proceeds fine and recognizes the new label (but, only, after clicking debug, not the first time through).
I need to figure this out because I have a much larger and more complex database with lots of labels and one label accidentally got deleted and when I re-created it from new, from the toolbox, I get this same problem, I also tried copying an existing label and that didn't help, and now I can't cycle through the labels.
Option Compare DatabasePrivate Sub Command4_Click()Dim lblDia As LabelFor Each lblDia In Me.ControlsDebug.Print lblDia.NameMsgBox lblDia.NameNext lblDiaEnd Sub
Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.