Option Explicit Variable not defined MVP recomended me start usi

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code:

Private Sub Text5_AfterUpdate()
If Text5 = "*pay day" Then Text5.ForeColor = 255
'Else: Text5.ForeColor = QBColor(0) 'Black

It worked fine however when I went and changed my code in my declarations
based on recomendation I got caught in this database.

Could someone please explain why also. I have only been in VBA for about 1
month and I do have some code with variables in some of the example databases
i have getting from the MVP web sites. The schooling would be much
appreciated.

Thanks,

Brian
 
I'm sorry, your question is not very clear. What do you mean by "got caught
in this database"?

The reason for using Option Explicit, which requires that all variables be
declared, is to eliminate errors caused by mistyping variable names.
 
By being caught I had sevral databases that I had to go back and add the
opton explicit to the code running behind the forms and some functions. I
used the data analizer in access that reccomended that I put option explicit
at the beginning of my forms. The code that I posted was the results of
using the on format selection tool when I designed the form. Access
generated this code I just used the tool.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top