Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-15-2018, 12:10 AM   #1
Programming
Newly Registered User
 
Join Date: Jul 2018
Posts: 20
Thanks: 5
Thanked 0 Times in 0 Posts
Programming is on a distinguished road
Programming with VBA and Macro

I created my first database project in Access. And I intend to set it up in a local network to be used among 4-5 people.

Some of the programming was in VBA and some in Macro.
My Questions is , will I have problems because of the some of the functionalities are in macro and some are in VBA?

The reason I did it like that , is because I am learning/searching along the way of creating the project. When I find an answer about what I want to program I use it .

Plz advice.

Programming is offline   Reply With Quote
Old 09-15-2018, 12:43 AM   #2
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,472
Thanks: 2
Thanked 2,003 Times in 1,959 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Programming with VBA and Macro

As I know, there are no problems mixing Macro and VBA code.
But VBA code gives you more flexability and options.
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
Old 09-15-2018, 12:43 AM   #3
jleach
Newly Registered User
 
jleach's Avatar
 
Join Date: Jan 2012
Location: New York, NY
Posts: 307
Thanks: 16
Thanked 69 Times in 69 Posts
jleach will become famous soon enough
Re: Programming with VBA and Macro

It should not present any specific problems. There's no reason macros and code can't intermix within an Access project.

__________________
- Jack D. Leach

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Microsoft MVP 2012-2016
jleach is offline   Reply With Quote
Old 09-15-2018, 01:10 AM   #4
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,445
Thanks: 92
Thanked 1,834 Times in 1,704 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Programming with VBA and Macro

Agree with previous two answers. However if you need help at any point, be aware that few of us here use macros so are less likely to be able to assist with those.
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-15-2018, 04:37 PM   #5
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,449
Thanks: 13
Thanked 1,422 Times in 1,355 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: Programming with VBA and Macro

One of the reasons that experts avoid macros is that in the past, there was no error handling support so errors would cause total failures in production environments. Just make sure you have error handling wherever it is needed.

And do not forget that your application should be split into FE (forms/reports/macros/queries/code) and BE (tables only)

The BE is stored on a shared network server and the FE is distributed so that each user has his own personal copy.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 09-15-2018, 10:00 PM   #6
Jeffr.Lipton
Newly Registered User
 
Join Date: Sep 2018
Posts: 25
Thanks: 24
Thanked 1 Time in 1 Post
Jeffr.Lipton is on a distinguished road
Re: Programming with VBA and Macro

I use both macros (for simple things, like closing the current form, or for things that are hard to do in VBA, like exporting to EXCEL) and VBA (for the myriad of things that can't be done in macros) in my database. I even have macros that execute code!

@Pat Hartman is correct that nthere's no real error handling in macros, though -- hit a "bump" and the macro stops cold.

ETA: If you just want VBA, you can create a blank form and put the steps of your macro into the On Open event, then click the "convert macros to code" button. Move the generated code to it's own module and delete the form.
Jeffr.Lipton is offline   Reply With Quote
Old 09-17-2018, 08:27 PM   #7
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,449
Thanks: 13
Thanked 1,422 Times in 1,355 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: Programming with VBA and Macro

If you know how to write VBA, nothing is easier with a macro.
I don't know of anything that can only be done with a macro but there may be something.

The problem with macros now that they actually have error handling is that they are still difficult to read there is no good tool to print them.

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 09-17-2018, 11:45 PM   #8
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,445
Thanks: 92
Thanked 1,834 Times in 1,704 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Programming with VBA and Macro

When problem solving databases, the use of embedded macros makes everything much more difficult as the 'code' isn't in a single place.

There are only two good uses for macros that I am aware of:
Autokeys - for creating keyboard shortcuts for certain actions
Autoexec - for startup actions

The actions in an autoexec macro can of course be done in other ways.
However, replacing autokeys with vba is much more difficult ... unless you use Sendkeys which I don't recommend
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
The Following User Says Thank You to isladogs For This Useful Post:
Jeffr.Lipton (09-18-2018)
Old 09-18-2018, 11:48 AM   #9
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 1,924
Thanks: 2
Thanked 413 Times in 406 Posts
Cronk will become famous soon enough
Re: Programming with VBA and Macro

I'll add some suggestions to that restricted list of macros.



I have one or two macros that I only use for housekeeping ie Relink which then run a procedure to relink between test and production tables.


Another instance where I use macros is where the same control in a form is calling the same procedure. Quicker to multi select the several controls and type the macro name once. The single line macro runs the error trapping procedure.
Cronk is offline   Reply With Quote
Old 09-18-2018, 12:29 PM   #10
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,445
Thanks: 92
Thanked 1,834 Times in 1,704 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Programming with VBA and Macro

Quote:
Originally Posted by Cronk View Post
I'll add some suggestions to that restricted list of macros.

I have one or two macros that I only use for housekeeping ie Relink which then run a procedure to relink between test and production tables.

Another instance where I use macros is where the same control in a form is calling the same procedure. Quicker to multi select the several controls and type the macro name once. The single line macro runs the error trapping procedure.
OK - but both of those examples could be done equally well (possibly better?) using VBA
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-18-2018, 01:27 PM   #11
Cronk
Newly Registered User
 
Join Date: Jul 2013
Posts: 1,924
Thanks: 2
Thanked 413 Times in 406 Posts
Cronk will become famous soon enough
Re: Programming with VBA and Macro

Code:
 but both of those examples could be done equally well (possibly better?) using VBA
In the cases I cited, macros have one line


Code:
Run procedureName
The macro is easily accessed on the Navigation Menu for me to execute the vba.


But to each his own.
Cronk is offline   Reply With Quote
Old 09-18-2018, 10:54 PM   #12
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,449
Thanks: 13
Thanked 1,422 Times in 1,355 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: Programming with VBA and Macro

I do have two macros in every database:
SetWarningsOn
SetWarningsOff

They are macros because:
1. They also turn the hourglass off and on so I have a visual clue regarding the state of the Warnings. Having warnings off is so dangerous that you really need something sufficiently annoying (like the hourglass) that you will turn them back on ASAP.
2. Being a macro makes them easy to execute from the GUI.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 09-19-2018, 12:45 AM   #13
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,445
Thanks: 92
Thanked 1,834 Times in 1,704 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Programming with VBA and Macro

Quote:
Originally Posted by Pat Hartman View Post
Having warnings off is so dangerous that you really need something sufficiently annoying (like the hourglass) that you will turn them back on ASAP
Agreed. So why use SetWarnings at all (even during development)?
Why not just replace completely with CurrentDB.Execute with dbFailOnError
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-19-2018, 08:05 AM   #14
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 27,449
Thanks: 13
Thanked 1,422 Times in 1,355 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: Programming with VBA and Macro

Because sometimes it's just easier to use DoCmd to run a query rather than DAO.

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

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro programming- how to generate text file with pre formatting. new2vbee Modules & VBA 0 05-26-2011 12:01 PM
new to db programming hydro Introduce Yourself 2 04-08-2010 09:41 AM
Programming with Macro krish General 2 01-13-2008 09:10 AM
[SOLVED] Access Macro/Module Programming... Please Help zephyrus Macros 1 06-23-2004 07:05 AM
Programming mls68 Modules & VBA 5 03-18-2000 05:28 PM




All times are GMT -8. The time now is 05:35 AM.


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

Featured Forum post


Sponsored Links


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