Coding in Access

  • Thread starter Thread starter Pete Davis
  • Start date Start date
P

Pete Davis

First a quick bit about my background. I'm programmer, but I normally work
with C++, C#, and so forth. I haven't done much with Visual Basic nor Visual
Basic for Applications and I'm a bit confused on the mechanics of it.

First of all, I've got an access form with a button on it. When the button
is pressed, I want to display the File/Open dialog.

I got this code: http://www.mvps.org/access/api/api0001.htm

and I'm a bit confused on where to go from here.

I went into "View Code" from access and copied the code in.

The first issue I get is about the Type definition. Upong trying to compile
I get: Cannot define a Public user-defined type within an object module.
Where does this go?

The second issue is with the Global Const definitons which give me the
error: Constants, fixed-length strings, arrays, user-defined types, and
Declare statements not allowed as Public members of object modules. Again,
where does this code go?

This would give me a good start. Thanks.

Pete
 
In the VBA editor, right-click in the Modules panel (left side of the
DE) and create a new module. Don't create an object module, just a
regular code module. Then, paste the code into it. Access will ask for
the name for the new module when you try to save it.
Or, in the Database view, click on Modules and choose Create new module.
VBA IDE is quite intuitive and you will have no problem migrating to it
from Visual Studio (or any other IDE for that matter).

Good luck,
Pavel
 
Back
Top