Go Back   Access World Forums > Microsoft Access Discussion > Theory and practice of database design

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-12-2018, 12:59 PM   #1
Gazza1709
Newly Registered User
 
Join Date: Sep 2018
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Gazza1709 is on a distinguished road
More Forms or More VBA

Hi all,

I have a form that I use for all my sales side orders (Quotes, Orders, Invoices etc), I use vba code to setup the form when it opens and also set the subform to use depending on the type of order.


My question is - Is it better to create different forms for each order or use vba code as I am to setup the form?

Gazza1709 is offline   Reply With Quote
Old 09-12-2018, 01:14 PM   #2
plog
AWF VIP
 
Join Date: May 2011
Posts: 8,807
Thanks: 10
Thanked 2,115 Times in 2,070 Posts
plog is a jewel in the rough plog is a jewel in the rough plog is a jewel in the rough
Re: More Forms or More VBA

Not really enough to go on. If they all use the require essentially the same data, then use just 1 form and then VBA to slightly customize it for each.
plog is offline   Reply With Quote
Old 09-12-2018, 07:05 PM   #3
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 12,178
Thanks: 58
Thanked 1,127 Times in 1,029 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: More Forms or More VBA

Unfortunately, there is no answer to that question without a lot more data AND without us knowing if YOU have a preferred way to work. There are cases where either answer is right and the other is wrong. And only YOU know what you really want to do.

plog's comment, however, is quite correct. The closer the special sub-forms are to each other, the easier it will be to just use the same form and maybe tweak it a bit. So you would use VBA to tweak the form. On the other side of that coin, if you have a single sub-form, you would be using VBA to redefine the form that gets plunked down into the sub-form slot and would have to reassert parent/child form linkages. So I don't see you avoiding SOME type of VBA no matter what you do.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Old 09-13-2018, 02:10 AM   #4
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 9,372
Thanks: 350
Thanked 761 Times in 726 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: More Forms or More VBA

Quote:
Originally Posted by Gazza1709 View Post
Hi all,

I have a form that I use for all my sales side orders (Quotes, Orders, Invoices etc), I use vba code to setup the form when it opens and also set the subform to use depending on the type of order.


My question is - Is it better to create different forms for each order or use vba code as I am to setup the form?
Well, quotes, orders, invoices, are essentially different stages of the same thing. In that a quote becomes an order and an order becomes an invoice. If there are only minor changes between the stages, then a single form presenting a VBA modified interface to manage each stage is ideal.

I'm not sure what you mean by "creating a different form for each order"?

Sent from my SM-G925F using Tapatalk
__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|                                     |
|                                     |
| Get $20 worth of "Nifty Code"       |
|      
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)
Uncle Gizmo is offline   Reply With Quote
Old 09-13-2018, 12:41 PM   #5
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,334
Thanks: 13
Thanked 1,403 Times in 1,337 Posts
Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light
Re: More Forms or More VBA

What are you saving by having a single form serve multiple order types?

My first inclination would be to use a single form but if the code is completely different for each type then it is better to clone the form and have clean code behind each version.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 09-13-2018, 01:44 PM   #6
Gazza1709
Newly Registered User
 
Join Date: Sep 2018
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Gazza1709 is on a distinguished road
Re: More Forms or More VBA

Hi all,

Thanks for the answers.

This wasn`t really a specific question as such, I was just wondering what the experts prefer to use. the orders example above was just an example of a business process.

From the answers I am guessing that if that more code is the way to go if it is all part of one business process.

Is there any speed and performance gain in doing it either way?
Gazza1709 is offline   Reply With Quote
Old 09-13-2018, 06:41 PM   #7
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 12,178
Thanks: 58
Thanked 1,127 Times in 1,029 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: More Forms or More VBA

Having the multiple forms ready to load with no other customization required is the fastest way. Having a lot of customization code that has to be executed during Form_Load events is probably not so fast, particularly if domain aggregates like DCount or DLookup get used.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Old 09-13-2018, 08:04 PM   #8
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 9,372
Thanks: 350
Thanked 761 Times in 726 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: More Forms or More VBA

As doc man alludes to, the biggest problem in loading speed is the number of Records loaded.

One trick I use is to have the default record source of the form set to select the zeroeth (0) record. You are practically guaranteed not to have a record number 0 so the form will load blank.

However I have never tested this, so I have no real idea if it does much good, I just think it does!

Sent from my SM-G925F using Tapatalk
__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|                                     |
|                                     |
| Get $20 worth of "Nifty Code"       |
|      
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)
Uncle Gizmo is offline   Reply With Quote
Old 09-13-2018, 10:02 PM   #9
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 1,846
Thanks: 2
Thanked 396 Times in 391 Posts
Cronk will become famous soon enough
Re: More Forms or More VBA

Quote:
so the form will load blank
Easier to have form's recordsource as
Code:
select * from YourTable where false
Alternatively, set the form's filter to
Code:
False=true
Cronk is offline   Reply With Quote
Old 09-14-2018, 09:03 PM   #10
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,334
Thanks: 13
Thanked 1,403 Times in 1,337 Posts
Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light Pat Hartman is a glorious beacon of light
Re: More Forms or More VBA

In the olden days we learned about coupling and cohesion. Programs/Objects should be losely coupled (have the fewest dependencies possible) and highly cohesive (about one and only one process - there should be almost no If's that execute different logic paths).

I once ran into an error routine that someone built with a nested If that went on for hundreds of tests. In the calling procedure, a number was assigned to a variable and then the "common" code was called. In the "common" code, the nested If looked for each possible error value and displayed the associated error message!!. It was a completely useless procedure. The procedure that found the error could just as easily have passed the error message into the "common" code to write the message which would have made the "common" procedure about 10 lines of code and the 200+ nested If could have been eliminated. This is of course what came to mind immediately as I read your question.

So again, if the code for the different types is not almost identical, then I would not attempt to reuse a common form. You actually have to be saving something to make this form uncohesive.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Tags
forms , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
When i open saved info on forms, show it on forms again? trizzytt General 5 10-06-2017 01:52 PM
Best Practice: How to Ensure Forms Dependent on Other Forms are Refreshed whdyck Forms 2 11-21-2012 06:53 AM
Required fields in forms and their sub forms. (Suppress warnings?) JGalletta Forms 7 03-29-2012 11:13 AM
Help with Forms List Box Double Click and Passing Info among forms dj_mix Forms 1 04-11-2008 04:34 AM
Open Pop-Up Forms Based On Criteria in Main Forms BlueFraggle Forms 3 07-25-2007 09:29 AM




All times are GMT -8. The time now is 03:06 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World