Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic code structure for writing VBA code in MS Access

Status
Not open for further replies.

LewisKing

Programmer
Oct 13, 2006
3
US
Hello I'm new here but i've been trying to find the answer to this question for a long time.

I need to learn VBA code for Access but what I need to know is how to structure the code I'm writing.

For example, in MS Dos if you see the following:

C:\Windows>IP Config

You know that C:\Windows is the Filepath and IP Config is the action, with > as the separator.

How do you do structure code in Access VBA?
 
The Dos command prompt is an entirely different animal than programming.

In your example c:\windows> is the command prompt.

ipconfig is a program that performs action/ and or displays results.

Batch files allow for simple programing and are dos based. They provide for simple tests (If Exists etc.) and support multiple actions all at once.

Access does not have a command prompt... It simply has modules where you put series of statments in procedures that will run when executed. Access is also Object Oriented, which provides a Graphical User Interface instead of a 'dumb' command prompt (think about menus in word and buttons in applications; all this is object oriented programming).

To learn Access VBA I recomend you buy or borrow a good book on the topic. I am a fan of Sybex as a Publisher. Litwin and Getz have been contributing authors to several books. But that's just me, I hate the For Dummies books. I am not a dummy, just give it to me straight.
 
I understand what you're saying....Maybe Dos Command was a bad example to use.

I'm familiar with objects, classes, and modules. What I need to know is how to structure statements. I know that every language has a base structure that you use to place command strings in the proper order so that your statement executes properly, in the proper order.

Take english sentence structure. You always put nouns before verbs right? Otherwise the sentence sounds like garbage. What I need to know is what rules govern statement structure for VBA in Access
 
There is no character that ends a line of code like in C or other languages.

Periods separate objects and collections / properties / methods.

If you install all the help, try looking at code examples for string functions...


Mid, IN, Left, Right

Also try looking at objects like Projects, Connections, Recordsets, Command.

 
I think you'll get up to speed on the basics of the language much quicker just by going through the first few chapters of any VB programming book.

Teaching the foundations of a programming language, even if sticking to just the core elements, is much to lengthy for a forum thread. And I doubt we could do it any clearer than any half-decent publication.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top