How can design view of a form be disabled by vba code and still display the contents of form correctly? - ms-access

I want to disable the design view of my from. Therefore, I saved my database as accde,doing so disables the design mode.However, doesnt load the form correctly.It isn't diplaying the information in drop down boxes as in the accdb file. It is displaying the drop down boxes where I have created a value list and not displaying the data in drop down boxes which have been extracted from a table.
Also, is there any way to hide my tables as well from the users.
Thanks Please assist

The VBA code needs to be compiled before saving the file into accde. Also, make sure the trusted location settins is turned on where the database file has been saved.

Related

MS Access: Allow user to update data from form, but not from table

I want to allow user to update data from form, but not from direct table. I added Before Change event on table, and raising error if the user group is 'basic'. This is working as expected if I enter data in table. But, it is also raising error even if saving data from form. Can anyone help me to resolve this issue?
Thanks in advance!
In general the way to deal with permissions in Access is to only ever show your users the forms; they should never directly interact with a table or query. So instead of adding Before Change code to your table, you instead want to hide the table.
The things you need are in the Current Database section of the Access options. For this example I'll assume you just have the one form, but the same applies if you have many forms and a "Home" form.
Use the "Display Form" dropdown to select the form you want the user to see when they open the application.
Un-check "Use Access Special Keys" to prevent keyboard shortcuts showing objects you don't want shown.
Un-check "Display Navigation Pane" to hide the object list.
Un-check "Allow Full Menus" to prevent users from creating new objects (or use other database development functions)
With this done, the user will see only the form interface you selected and the basic data entry toolbar.
Note that when you want to make changes to the file as a developer you must hold down Shift when opening the application, which will display the navigation pane etc. Of course, any user who knows about the Shift override could do the same. Which is why distributing in a compiled accde, which cannot be unlocked, is a good idea. But you need to set up the application using the above options before that matters.

VBA to create a form and load an attached image to it

Client has asked me to create a self contained tool in MS Access, versions 2007 and 2016. It needs to be self contained because it will be copied to and from various laptops at various times. The tool may not create, delete, or modify any file except the accdb database itself. When the tool is in use, the user is unlikely to have network or internet access.
One of the criteria is the creation of new forms each time it is run. I realize that Access is meant to have all the forms and their controls already built before deployment, but client doesn't want that. I have solved that problem, creating x number of forms upon certain conditions, and creating 30-40 controls on each form based upon certain conditions, each with their own events, etc.
Now, how do I load his logo into a control on each form? Remember, the accdb must be self contained, so I can't count on the logo being in a certain directory or even on the machine in use, and I can't write it to the file system myself.
I can and have loaded the logo (jpeg) into one of my tables in an attachment field. It will be the only attachment in that field. It would be just as easy for it to be its own table, if that helps.
I can create attachment controls with VBA, but I don't know how to set the ControlSource to the FileData inside the attachment with VBA.
I also have had poor success attempting to embed the picture in an image control in a hidden form and setting the .picture property to the image name. It only seems to be working on my machine.
So, how do I display an attached jpeg on a newly created form?
Just asked and answered in SO access-vba. Here's one solution.
Saving Image as OLE Object, in Access
Many others on google and SO search
EDIT: You must read the whole question to see the author's answer
Answer:
So, what I ended up doing was following this
https://support.microsoft.com/en-us/kb/210486
I use the readBLOB function to read the file and save it into the
database. Then, when I run a report or open a form that has the
picture, onload, I use the WriteBlob function to write the file to a
temp folder and then use that path to populate an Image object.

Create a standalone form shortcut in Microsoft Access 2013

I currently have a functioning form that searches through my database by calling a query. What I'm trying to do is turn this into a standalone application where I can simply open a file and only the form opens, running the database on the back-end. I have tried running a macro that opens the form, and I have tried creating a shortcut to my desktop, but nothing has worked.
Does anyone have any suggestions? Anything that will only show the form and the search results would be good (desktop shortcut, HTML file, etc.).
Thanks!
You will need to split your database so that the tables are located in a separate back-end file (which can be kept on a server). These instructions apply to Access 2007 and 2010 but the process is very similar for 2013.
Once this is done, your tables will become linked tables (stored in a separate file) and your front-end .addcb file will only contain queries, forms and reports.
You can control which form opens when the application loads through File -> Options -> Current Database. There are also several other useful controls here for limiting what the user can do; ie.
Hiding the list of database
Hiding the tabs (you will therefore need to create buttons to move between forms)
Hiding the Ribbon and/or status bar
Disabling Layout View
It's safest to change these settings on a copy, so you don't inadvertently lock yourself out; however, by holding down shift when opening the file from within Access, most of these options will be bypassed and you will be able to edit the database / revert these settings should you need to.
In terms of making it a "stand-alone application", it is possible to create a copy that will open without requiring the full version of MS Access on the user's PC (instead using Access Runtime).
I always distribute my front-ends as .accde format (File -> Export ACCDE). The benefits are as follows:
Smaller file size
Optimise memory usage / improves performance
VBA code runs but cannot be viewed or edited
I think what you're looking for is here:
http://office.microsoft.com/en-us/access-help/command-line-switches-for-access-HA010166605.aspx
and
http://office.microsoft.com/en-us/access-help/command-function-HA001228801.aspx
Basic idea, create a macro called AutoExec that checks for a command line argument when opening the database. Setup a shortcut with a command line argument (whatever you decide to name it, I'll use 'lookuponly' as the example.) like this:
"C:\Users\%Username%\Desktop\MyDatabase.mdb" /cmd "lookuponly"
when you double click the shortcut it should auto-run the macro and open your lookup form. Of course under newer versions of access you'll have to set the location of the database as a trusted location or access will attempt to block the database.
http://office.microsoft.com/en-us/access-help/decide-whether-to-trust-a-database-HA010256412.aspx

Large Forms Design Using MS Access 2010

i am trying to make a form design in Ms Access 2010, for that firstly entered fields into Access Table. Then try to
Create->Form Wizard
Actually my table is too big, so form wizaed is not creating the form . Also i want divide this form into separate parts. I tried "Tabs". But My problem is that when i take the printout of form i want actually get the full form in one print. If i use Tab, that is not possible. How can i solve this problem.
Thank You All
You can use tabs if this is working for you and also create a report that includes all the fields that you need to print out. This report can be activated by a Print button.

Add A Background

I was wondering if there was any way of changing the background in access. The standard grey is ok but I would like to change it to an image that shows instructions or what was updated last. Also, if I can allow a user to change the background to an image of their choice that would be cool as well.
Can this be done
To be honest, I'm not sure if this is possible or not, but if it is, I'd advise you not to do it. Why?
Users will expect instructions under a help menu or on an intro
splash form
They will expect info. like what was updated last to appear in more
conventional places like the status bar
Allowing users to personalise your application with their photos can
make your application look pretty bad and increase load times.
Only advice though - good luck with it!
I have been able to allow users to change the background of the database. It works great and it works no matter what computer they log onto the database from. I did have a problem with remote users so I added a macro that allows them to disable the functionality. It works great. It was a little complicated to se up initially. Some of the modules below may have more stuff contained in them then what is needed for the purpose of this question. But here is what I did to make it work:
Add the Following modules to your database: modChangeMDI, SetBackgroundImage, and clsCommonDialog
Link to a zip file containing the code for the above modules: http://www.filedropper.com/changebackgroundimage
You can set the default location that a users sees when the search for file dialog pops up. This is located in the ThisFileToOpen function of the SetBackgroundImage module.
clsCommonDialog <-- Used to open the find file dialog box
modChangeMDI <--Used to change the background image
Create a table called $BackgroundLocation with the following fields. On my database this is contained in the backend database.
ID (AutoNumber, Primary Key)
UserID (Text, Required, 250 in length, don't allow zero lengths)
BackgroundLocation (Text, 255 in length, not required)
DisableBackground (boolean)
Create an AutoExec macro and add an action that runs the code SetTheBackgroundPictureOnStartup (1)
Create a BackgroundDisableEnable macro and add an action that runs the code DisableEnableBackground()
Create a BackgroundSet macro and add an action that runs the code SetTheBackgroundPictureOnStartup(2)
Then assign the BackgroundDisableEnable and the BackgroundSet macro to their own menu item.
When the database opens it will run the AutoExec by default.
You can use a start-up form as I suggested above. You can even base the start-up form on a comments table that can be edited by the users and will display the most recent and / or relevant information. The form can be displayed at start-up and then referred to at any time by the users.
In the past, I have included a ? button on forms that open such a form at the relevant page.