At 13:55 a VBA command does not run because we did not Dim our variable (My Reply). However at 18:16, when we use a variable my password without "diming" it, the VBA command runs perfectly. At first i thought it would bring an error but when i tried it on my database, it worked well without "Dim MyPassword". Why does it work in this particular case? Help me and clarify. Thank you,
MICAH
Reply from Richard Rost:
You only NEED the Dim command if you have "option explicit" specified at the top of your VBA code. If that's there, VB will force you to EXPLICITLY declare all of your variables. If not, you don't have to. It's GOOD practice to leave this setting ON because it avoids mistakes in your code due to misspelled variables. However, it slows down the development process because you have to take the extra time to manually Dim all those variables. Your call.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Microsoft Access 306.