change property of form control and save the changes (1 Viewer)

Cowboy_BeBa

Registered User.
Local time
Tomorrow, 00:33
Joined
Nov 30, 2010
Messages
188
Hi all

This is a bit of a random one and i hope you guys dont mind if i ramble on a bit, because even though the question is simple enough im not sure if im approaching my problem the right way (ie, not sure if i even need to worry about saving changes to a form property..... which i think happens automatically anyway?)

anyways heres the cliffs notes of the backstory
-Building an ERP/MRP DB in access with the intent to sell it to any small/medium companies who need one but dont have the cash to spend on one of the bigger budget ones on the market. Its not quite done yet but hoping it will be ready in the next few weeks.

-Because im selling this to different companies (and offering them training, maintenance and bug fixing), i figured the best thing to do would be to create a user settings table. As part of the setup for each company id run them through a "setup wizard" im working on. They should be able to import data and, most importantly, set certain variables for the program. For instance the colour scheme of the forms and the logo used on each page/report
The reasoning behind this was that if i sell to a lot of companies, it would be a royal pain in the bum to go through every page, each time, change everything manually (and make sure i didnt forget anything). Then, whenever i release an update i would have to make changes to every front end ive made for each client.
With that in mind i built the front end so that all i needed to do is update one front end. Send a copy to each of them and their settings would automatically be loaded when they run it.

-Currently the settings are all being loaded using dlookup's to load each,
Me.imgLogo.Picture=dlookup(blah blah blah)
Theyre all in a table called tblSettings. Just has 3 fields, an ID, a text field that describes what the variable is (so that i and any other users will know what we're changing) and a text field called setVariable. Each setting is a a different record on this table. Only i am able to add/delete records and change a description. The user can change the variable.
Im aware this might cause a small lag (when the back end is loaded onto a server and a couple users are all running the front end from their desktops simultaneously, every time a form or report loads thered be a lag while the front end looks for the variables it needs and changes the relevant form properties), so im writing a module that declares a list of the variables from the settings table that i need and sets them as the appropriate dlookup values, Planning on running that module the moment a user loads the DB, it should take a lil while to load initially but hopefully will operate quicker when the db is running
This part isnt actually relevant to my current question, but figured while im writing up the entire story i may as well ask, does this seem right to anyone else? just wondering if my reasoning is sound. Its a bit of effort to change and im just curious if its worth it, or if it will even make a difference to speed of the db.


Now, the final part (sorry for the whole backstory (and the big digression), i tried to keep it brief), the problem im currently having is with the Logo. Its just a simple picture box (its actually the Auto_Logo that is generated when you create a new form or report, just resized and renamed).

When testing the logo feature i noticed that once i loaded a logo initially, if i either changed the logo (in the db) or deleted it (both the file itself and the db entry, same result with just one or the other) when next i ran the db i would get an error message whenever the logo was loaded
"Microsoft Access cant open the file '" & filepath/name &"'"

I'm trying to stop this error from popping up and cant seem to. When i first put a file name in the settings table and loaded a form that file name and path was loaded into the Picture Boxes (imgLogo) Picture property. Even if i go into design view and delete the relevant form property i still get the error message

What im wondering is how do i find a way to prevent this error from happening?
Currently ive got a small if statement that runs at every form load. it checks if the image file even exists. if it does then it loads imgLogo with that image file (me.imgLogo.picture=whatever), else it just sets the picture property to "(none)", which is its default when no picture is present.
Even this however wont stop the error. Each time the form loads it still seems to be looking for the first image file i loaded onto it
My idea is to add me.imgLogo.picture="(none)" to every form_unload to see if that changes anything.
It doesnt seem to, wondering if perhaps the change in the form property is not saving when the form closes?

Either that or changing the picture property does nothing to remove the link it has with the original file i loaded (it doesnt really appear to do so.... other than to display nothing when there is no logo... which i guess might happen anyway)

Btw, i keep saying "Original Image", because since then ive changed the image a dozen times over, the image will load correctly, but ill still get that darn error message

Sorry for the long essay guys (and, if youve gotten to this point, thank you so much for bearing with me and reading through it, hope i supplied all the info needed), but after reading all that, any advice?
 

sneuberg

AWF VIP
Local time
Today, 09:33
Joined
Oct 17, 2014
Messages
3,506
I tried to replicate your problem in the attached database and was unable to duplicate your symptoms. Maybe I'm doing something different. I suggest you take a look at the form load event code and see if you can see a difference. Please note that the Picture Type in the form's Auto_Logo0 is set to "Linked"

If you open the form in the attached database it will create a .bmp file (clock.bmp) in the folder in which the database in located. This is caused by a feature that you might be interested in. If the code doesn't find the image file it creates one from an image store in an OLE Object field. The code that loads the OLE Field and outputs it to a file is in the Common Procedures module. It's not well documented. I'm taking the chance that you'll be able to figure it out. If you have any questions let me know.


As an aside we started storing images in BLOB (OLE Objects) when our users started deleted image files that were required for some word documents that our code created. Actually they delete the entire folder they were in. The name of the folder was "Required Files". Probably should have named it. "Temporary Stuff That You Can Delete Anytime" :rolleyes:
 

Attachments

  • LoadAutoLogoImage.accdb
    412 KB · Views: 271
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:33
Joined
Feb 28, 2001
Messages
27,133
It is totally possible to open a form from VBA in design mode, make changes, and save it. I would not advise doing so from a class module for the same form that you are opening in design mode, though. This is one of the few cases where you might wish to usa a macro with a runcode action. You would launch the form for this design change by giving your user a script that uses a "-x macroname" command-line option to launch VBA not bound to a form, but to a general module that contains your customization code.
 

sneuberg

AWF VIP
Local time
Today, 09:33
Joined
Oct 17, 2014
Messages
3,506
It is totally possible to open a form from VBA in design mode, make changes, and save it.

However I believe users will need full Access if you have that in your application. I worked with a forum member on a project in which he want to give his users control over the font names, sizes, and colors of the output report. We got that set up nicely but after all of that effort we found out it was for naught as he needed to distribute the application as an .accde runtime application.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:33
Joined
Sep 12, 2006
Messages
15,634
I would use (and do use) a "settings table" with values such as "logo file name", "terms and conditions Filename ", and so on.

At run time each form/report that needs to makes whatever changes are necessary, based on the appropriate settings values.

The only issue is (say) if one user a long thin logo, and another user needs a square one. It's hard to suit everyone.
 

sneuberg

AWF VIP
Local time
Today, 09:33
Joined
Oct 17, 2014
Messages
3,506
The only issue is (say) if one user a long thin logo, and another user needs a square one. It's hard to suit everyone.

Why is that an issue? Can't the height and width be stored in the settings table and set during the form load?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:33
Joined
Sep 12, 2006
Messages
15,634
maybe, but you can't necessarily accommodate every wish list in a single form design.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:33
Joined
Feb 28, 2001
Messages
27,133
If the logo is used as a background, then you can do something for everyone. If the logo is used in, say, an upper corner of the form, then the rest of the controls on the forms might overlap that logo if it is of an abnormal size.
 

Users who are viewing this thread

Top Bottom