Hi All
I'm declaring a global variable and getting the above error message
Any help will be much appreciated.![]()
Please Login or Register to view this content.
Thanks
Hi All
I'm declaring a global variable and getting the above error message
Any help will be much appreciated.![]()
Please Login or Register to view this content.
Thanks
Hi aman1234,
It seems like you did not declare a Sub or Function. Your code should probably look something like:
The above code compiles fine with a value of '(TO>#12/01/2015# or TO IS null)'.![]()
Please Login or Register to view this content.
Option Explicit is very important
It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
This option requires all variables to be declared and will give a compiler error for undeclared variables.![]()
Please Login or Register to view this content.
Lewis
The sql1 = ... line must be in a sub
I need to use the value of sql1 many times in the code so that's why I want to define it globally so that I can use it as many times as I want . please see below:
Im getting invalid outside procedure error. Any help will be much appreciated.![]()
Please Login or Register to view this content.
It must go in a sub, just make sure the sub runs before all your other code
kyle123, so how can I use the value of sql1 in combobox1_change() event?
Try something like:
![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks