Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eval function help please

Status
Not open for further replies.

hopper

Programmer
Dec 5, 2000
27
0
0
US
Since there are no control arrays in VBA (that I know of...) I'm using a for loop with the eval function to try to clear out some labels... for whatever reason, I get an error message stating
"Microsoft Access can't find the name lblFname0 you entered in the expression"

however, that is the correct name for the label I want to access...

here's my code:
For i = 0 To 14
Eval("lblFname" & i).Visible = False
Eval("lblFname" & i).Caption = ""
Eval("lblLname" & i).Visible = False
Eval("lblLname" & i).Caption = ""
Eval("lblType" & i).Visible = False
Eval("lblType" & i).Caption = ""
Eval("lblPhone" & i).Visible = False
Eval("lblPhone" & i).Caption = ""
Eval("cmdContact" & i).Visible = False
Eval("lblContactID" & i).Caption = ""
Eval("lblSubID" & i).Caption = ""
Next

Any clues as to why this isn't working? I'm using Access 2000.

Thanks for any help!

Hopper
 
Access does have control arrays. Something like...

For x = 0 To 4
Me.Controls("label" & x).Caption = Now()
Next x


Mike Pastore

Hats off to (Roy) Harper
 
Access is looking for a string expression. Take a look at the help for eval in Access. It has some good examples and a good explanation. I was able to get it to work w/o to much work.
 
Me.Controls() works perfectly!!! Thanks!!!

I'm still looking at the Eval function to figure out what I did wrong. I know I used that before but it was Access 2002 and I wasn't sure if there was something different there or not..

Thanks for all your help!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top