Question What is best...? Code or control...? (1 Viewer)

Dezirous

Rafi Ahmed
Local time
Today, 18:31
Joined
Jul 8, 2009
Messages
71
Hi Experts,
I want to ask that what is the difference using if I use form or report using form properties dialog box to configure its caption, source, permissions of add, edit, delete etc OR using source code to set source with SELECT command. Does this improve the efficiency of form or not................?

Thanks in advance...........
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:31
Joined
Jan 20, 2009
Messages
12,851
Code is used to dynamically control the form or report properties. If they never change they may as well just be recorded directly in the properties.

Where properties do change during runtime it can be advantageous to set their initial state OnLoad. This way they are guaranteed to start in the right state. I think most developers would have experienced a moment where they messed up a form by inadvertantly saving after dropping it into design mode when it was in an altered state due to VBA controlled changes.
 

Dezirous

Rafi Ahmed
Local time
Today, 18:31
Joined
Jul 8, 2009
Messages
71
Thnx bro............. does this mean that professionals prefer to use coding method for development............? I'm asking it because I'm not professional............ :(
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:31
Joined
Aug 30, 2003
Messages
36,124
Maybe you should be more clear about your situation. As Galaxiom said, and I agree, if the properties aren't changing, just set them in design view so no code needs to run.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:31
Joined
Jan 20, 2009
Messages
12,851
The coding method is just a way to change the design of a form while the program is running. If it doesn't need to change then we just use properties because that is easier. Most coding is used to enable of disable controls as required, jump to particular records, open forms and reports etc.

However it also allows the developer (that is all of us not just the pros) to design one form and reconfigure it as it opens to work with different tables or queries as the record source. It can save work and keeps the appearance and style consistent across what looks like different forms and reports.

It is even possible to use code to create a database from nothing, making tables, queries, forms and reports from scratch. The main factor is reducing effort.

Once you are fluent with code it can save a lot of time. For example I have a module that automatically creates buttons for every form in a database.

Everything in Windows can be controlled by code. Install, open or close programs, get webpages, change user settings. The list is endless.
 

Dezirous

Rafi Ahmed
Local time
Today, 18:31
Joined
Jul 8, 2009
Messages
71
Now I got the point that properties dialog has limitation and just to control appearance of form or report and some basic needs, but coding explorer all the way what ever you want to do...
Actually, I have seen some modules code which were so hard to understand on beginner level, and still hard to remember... If I want some code which I can't remember, usually I use copy paste method from existing project to new one...
What professionals do on these cases........?
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:31
Joined
Jan 20, 2009
Messages
12,851
We copy and paste.

However the VBA editor has a great feature of prompting with the valid choices as you type. You have to use the dot operator everywhere in your code as it doesn't work with the bang(!).

Choose the term you want and hit dot, space or return and the choice is inserted.

Eventually you get will understand the syntax and be able to type it right. It is a nice feeling the first time you type something and it works straight up.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:31
Joined
Aug 30, 2003
Messages
36,124
Many of us also use code libraries of some sort for frequently used code. I use MZ Tools, which has a nice code template feature.
 

Users who are viewing this thread

Top Bottom