Having trouble with 2013 Form Modules

bookman

New member
Local time
Yesterday, 22:49
Joined
Nov 16, 2014
Messages
3
Can't find any way to declare variables in the sort of module that Access uses by default.

Having changed the default, I now get 'Option Compare Database' as the first line (previously nothing was there). Adding anything at all in that section, or changing it to 'Option Explicit' has the consistent effect that all the procedure names in the module are not recognised and nothing works.

Variables declared in procedures work only in the procedure even if declared as Public. Can't get a Static variable to work in more than one procedure.

However many variables I declare, there are never any in the Declarations list at the top of the Code Window.

What am I doing wrong?
 
"the sort of module" ..WHICH sort of module? Variables do not automagically appear in any list of delcarations unless you put them there. SHow screenshots (put them in a zip and upload) or else this will be a lengthy exchange to identify what you have.
 
Here is a screenshot.

I meant the type of module Access gives you by default when you make an Event Procedure and choose 'Code Builder'
 

Attachments

you generally need

option compare database (which is a default) AND
option explicit

option compare database deals with whether strings are processed as case sensitive or not, etc. http://support.microsoft.com/kb/98227

option explicit corresponds to options/require variable declaration in the vba section

option explicit tells the compiler that all variables must be declared before use, which is recommended, although not default.

you declare variables before use within a module or a procedure

eg
dim somevar as vartype
 

Users who are viewing this thread

Back
Top Bottom