Using string as code

rafa.toshio

New member
Local time
Today, 17:11
Joined
Feb 4, 2010
Messages
8
Hi everybody,

I have a problem. I need to search the name of a form into a table and use them to construct my code. Like this:

strFormName = "MyForm"
strButtonName = "MyButton"

Form_strFormName!strButtonName.Visible = False

And it need to make the button "MyButton" on the form "MyForm" invisible

Is it possible?
 
Yes you can do what you want to do.

Try this:
Forms(strFormName).Controls(strButtonName).Visible = False
 
Thanks Mr. B, but I tried and doesn't work. Access can't find the fild....
 
Thanks Mr. B, but I tried and doesn't work. Access can't find the fild....

You have to first assign the values to the variables using a DLookup for each to get the values out of the table.
 
Hi,

You need to make sure the form is open in normal view. Other than that, check your spelling or something because it should work (I use it quite often myself...).

Simon B.
 
I'm sorry everybody.... The code work. The error I was seeing is due another part of my code that occurred after I make changes to test.



Sorry again :o
 

Users who are viewing this thread

Back
Top Bottom