Access 2007 - vba instead of Macro - ms-access

I dont want the buttons to produces "embed macro" . I tries to press the convert icon to VBA , but still when i use the wizard of buttons it remains to be macro instead of vba procedure , why ?
thank you

Create a button without the wizard.
Right-click on the button and select Build Event. Choose "Code Builder"
The Microsoft Visual Basic IDE should open.
You can also access the buttons events from the Properties Sheet | Event tab.

Beginning with Access 2007, Microsoft built a stronger, more capable macro system that they hope will be able to mostly replace VBA due to the inherent security differences between VBA and macros. There is not, as of yet, a simple way to make Access 2007 or 2010 create VBA code instead of macros when using wizards.
There are two ways some people have had success getting Access to create VBA or converting macros to VBA.
Create an Access 2003 database (.mdb) file. This will create a db compatible with the older versions of Access that don't have the robust macro system and so the code created will be VBA for the most part. The drawbacks of this will be if other functions in your database require the newer Access functions.
After the macro is created, save it as a separate macro rather than an embedded macro. Then in the Design ribbon in the Tools group, the Convert Form's Macros to Visual Basic should work more reliably. The converter is still not very reliable, and if it errors out, there is usually not a way to fix the issue.

Related

How did my company build a program on top of Microsoft Access?

My company hired an outside firm to build a complex program for them through Microsoft Access. The program is designed to link with a second access database, run a series of linear equations in the background, and spit out a few reports. As a user, I interface with a simple GUI in the Access file to 1) tell it which database to link with, 2) manipulate some data, and 3) run reports.
If possible, I would like to see the back end of this program to see the programming logic and to identify how it creates the reports. I am familiar with the basics and the methodologies of Microsoft Access, but don't know much about the dedicated functions of the application.
Thank you for your advice!
The Access / GUI file is actually the front-end, whilst the database you select in the GUI will be the particular back-end you're dealing with. The coding is most likely to be in the front-end as VBA (or as a series of queries, macros & reports).
So, try holding shift when you double-click the Access file, which will try to load the GUI in "design" mode. As #June7 noted though, if its a locked-down / executable mde or accde this won't work, it'll need to be mdb or accdb. You'll also require a full version of MS Access, not just the free runtime installed on your machine.
If you manage to open in design mode, you should be able to see any tables, queries, forms, reports & VBA modules in the navigation pane on the left of the screen... unless of course, they've made them hidden objects. The can be unhidden if this is the case, though.
There may also be password-protection on some parts (which is easily crackable using info you'll find on Google).

Is it possible to run a VBA file from a VB6 application?

I have a very large amount of code written in VBA in Access .mdb files, containing forms and connecting to an Access data base. I need to migrate this code to a VB6 application. It isn't practical to rewrite all of it as there is just too much.
Is there a way to call that VBA file from a VB6 form with buttons, that would allow users to launch each one of these VBA modules, via a simple click on its corresponding button? What line of code in VB6, allows to launch a VBA file?
Update
I finally succeeded to figure out how to launch a VBA mdb file from my VB6 form using this instruction :
Call Shell("C:\Program Files (x86)\Microsoft Office\OFFICE11\MSACCESS.EXE C:\presto.mdb /runtime /cmd", 1)
So the VBA project is now launched from the VB6 form, but it crashes, at start up, showing this error "Runtime error ‘3024’ Could not find file ‘C:\db.mdb’".
I feel like I'm half way to thee solution. But I don't know what am I missing here?
Without knowing the structure of your VB6 application and your access files and what they do, it is virtually impossible to give any sort of useful answer.
What you want to do is not easily possible, as stated in comments VBA projects are not designed to work in this way.
However here are some suggestions.
Investigate the RunMacro command and see if this is of use to you.
You could try to use a tool like autohotkey to record mouse clicks where you want them and replay from your VB6 app.
Look at pulling out sections of VBA that are business logic and directly copy and paste code into your VB6 app. This may or may not work depending on the code.
Begin the slow process of rewriting (but don't rewrite in VB6, use VB.Net, C# or do a web app or something at least resembling a 2015 application).
If you want my honest advice begin to migrate to a more modern solution such as VB.NET so you won't have an even worse problem in 2020.
There is NO silver bullet for your problem.
It would be better to design a new form in VB6 with button as you said but also with some text(s)/list(s)/whatever(s) you want to display the results, then you copy/paste VBA code into button_click(s) event(s) to execute it and add to that vba code some output to the text(s)/list(s)/whatever(s) you decided to put on the VB6 form.
Edit : Ok, so taking your comment in consideration perhaps that trick could help avoiding re-write thousands of line code : add in the VBA code a while loop that trigger some Sub or Function on the presence of a flag on the system (a specific c:\temp\fileFlag.txt for example) so as soon as it appear the VBA code is called... if the VB6 control the flag would it do the job ? :)

2010 Access Runtime - Missing functions for 2007 users?

I have an Access database for which I have created a 2010 runtime version.
I sent over to a partner in India where their predominant machines only have Access 2007 installed.
They have installed Access 2010 Runtime to these machines, but make the following claims:
No access to Nav Pane - to see/open tables
No menu ribbon
No table/datasheet right-click functions (sort, find, etc.), except as I have implemented under buttons on the form.
I see all these functions when I run on a 2010 VM. I don;t have a 2007-only machine to validate or debug their claims.
Does this result sound odd?
I suppose I could work around some of these:
Populate the current list of tables in a listbox on the form
Create a custom menu with the necessary functions
Not too sure about the table/datasheet right click functions
Not freaking out just yet, but getting close... I cannot re-build this thing DOWN to 2007.
Any advice anyone?
Does this result sound odd?
Not really. It sounds like you were opening the .accde file using the full Access 2010 application while the other team was opening it using the Access 2010 Runtime.
The Access 2010 Runtime environment does not include things like the standard ribbons, navigation pane, etc.. If the developer intends to deploy the Access application under the Runtime then the expectation is that they will provide custom ribbons and navigation tools as required for that particular application.
Note that this is true whether the Access application is distributed as an .accdb file or an .accde file. An .accde file is simply an .accdb file with the VBA source code removed and the users being prevented from opening objects like Forms and Reports in Design View. Those changes help "lock down" an application when opened in the full Access application, but they don't make any difference to the behaviour when opened in the Runtime environment (because the users can't perform those operations in the Runtime environment anyway).
Developers can test the "Runtime" behaviour of their applications by opening them in "Runtime mode" in the full Access application. This can be accomplished in either of the following ways:
Create a shortcut that invokes MSACCESS.EXE with the /runtime switch and passes the name of the .accdb file to open.
Temporarily rename the .accdb file to .accdr and open it. .accdr files automatically open in Runtime mode.

MS Access Issue - VBA Editor appears during runtime

I am about to release an Access Database application where the UI is used exclusively to interact with the database tables.
Whilst I am interacting with the forms during run time, the Visual Basic Editor appears with a line of code highlighted in debug mode, even when no breakpoints exist and no run time error has occurred.
Has anyone else come across this issue?
I need to ensure that the editor does not appear (under normal operating conditions) while the user is interacting with the application.
Thanks.
Yes, I have had this problem too and it has driven me batty. The quick and dirty way of fixing it is to create blank database and import all of the objects from you old database into the new one.
Are your users working with an .accdb file? (or .mdb, depending on the Access version)
If yes, you should convert it into an .accde/.mde before giving it to your users.
Quote from the link:
Additionally, if the database design needs to be secured to prevent changes, Access databases can be locked/protected (and the source code compiled) by converting the database to a .MDE file. All changes to the VBA project (modules, forms, or reports) need to be made to the original MDB and then reconverted to MDE. In Access 2007 and Access 2010, the ACCDB database is converted to an ACCDE file. Some tools are available for unlocking and "decompiling", although certain elements including original VBA comments and formatting are normally irretrievable.
--> since .accde/.mde files are compiled, it's not possible to view the source code at all.
So the VBA editor can never appear accidentally like you experienced...be it because of a breakpoint, some Stops in the code or some strange breakpoint error like yours.

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application.
In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by the way Access does it.
Therefore I want to make my little piece of code to list the macros, their instructions list and parameters to the debug window or to a text file.
I googled but did not find much on what object(s) contain those macros.
Any clue to put me on track ?
Have you tried the built-in database documenter that will printout all of the macro code in one shot for you?
Go tools->analyze->documentor
This feature allows you to printout all macro code in the whole application