EVAL calling procedure 3 times
Posted on 2003-03-28
Hi. This is my first question, so forgive me if I don't do it right.
I'm alternating between Access 2000 and Access 97, and have the same problem in both versions. I have a form with several checkboxes (check1, check2, and check3 for testing), and I want to call a corresponding procedure programmatically if the checkbox is checked. Through research, I discovered that I should use the "Eval" function. Here is the code I put together:
Private Sub Command0_Click()
Dim ctlName As Control
For Each ctlName In Me.Controls
If TypeOf ctlName Is CheckBox Then
If ctlName.Value = -1 Then
Eval ("Forms!Form1." & Mid(ctlName.Name, 4))
Public Sub ck1()
Public Sub ck2()
Public Sub ck3()
The only problem with this code is that it runs each procedure 3 times. Here are my results when boxes 1 and 3 are checked:
When stepping through the program, it does not return to the Command0_Click procedure before repeating the ck# procedure. When it is done with ck1, it goes directly from "End Sub" to "Public Sub ck1()" again.
I would ask "can anyone help?", but I KNOW that someone at Experts-Exchange can. :)