We help IT Professionals succeed at work.

Best practice to save just one piece of information that might rarely change.

peispud
peispud asked
on
Hi.

My application will generate PDF's.     Those PDF's will almost certainly be always saved the same chosen folder.   But a different user may want to choose another folder.
So, what is the best way to save the file path (string)?

1) I could store the path string to a constant.    This is OK for me, but not for a non-programmer.  
2) I could create a  table with one record and one field.      If I wrote code around that, then the other users could change & store the information.  
3) I could create XML file.    But now, I would have to do some coding to handle a situation where the XML file was not there  (for various reasons).

Is there a better solution?
Comment
Watch Question

omgangIT Manager
CERTIFIED EXPERT

Commented:
For a lot of my MS Access applications that have connections to a SQL Server back-end I store the SQL connection strings in a table with two fields, one for the PROD conn string and one for the TEST/DEV conn string.  I have a function in VBA to change the application's connection to the back-end db using one or the other conn strings.
This works for me.  The conn string is rarely changed once the app is deployed but allows me, or a user, to change it if necessary.
Owner, Dev-Soln LLC
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2010
Commented:

I generally have a table called tbl_App_Data, which contains fields (AppProperty (text 30), Debugging (Yes/No), PropValue(text 255)).


I use this table for a wide variety of purposes, but you might use;


AppProperty             Debugging       PropValue
Def_Save_PDF_Folder         0           \\servername\Folder\subfolder\
Def_Save_PDF_Folder        -1           C:\Working\AppName\TestReports\


Which you could then get the folder from with:

 strFolder = GetProp("Def_Save_PDF_Folder"
 , -1)

using:

Public Function GetPropStr(PropName as string, optional Debugging as boolean = false) as string

    Dim strCriteria as string
    strCriteria = "[AppProperty] = '" & PropName & "' AND [Debugging] = " & Debugging
    GetPropStr = NZ(DLookup("PropValue", "tbl_App_Data", strCriteria), "")

End function


peispudTech

Author

Commented:
HI.

Thank you for your quick reply.
Your assistance has been appreciated.
John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:

Another solution not mentioned is to use a different DB engine just for storing the PDFs as Blobs ...probably Firebird.

So no more chasing folders.

In the proposed solution i would modify it like this

Table :

      ID                      User(PK)         Application (PK)   File (PK)        Location   SaveActionDate                

AutoNmbr          Number             Number                     Number       Text        Date                           

So for every save action you log which user from which application saved the particular PDF to which location and when.

I assume that your PDFs have some kind of uniqueness so the exact filename would be saved them to a separate table. (ID, FileName)