Results 1 to 7 of 7
  1. #1
    Turncloud is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2013
    Posts
    22

    Exchange rate variable - making it global

    This is probably an obvious question, but I've not found an answer so far..

    I have an Access 2013 application. There are two main tables, one of companies and the 2nd which references files relating to those companies. The database is a split access database.

    I need to add a variable that contains the current Exchange rate and naturally this needs to be global. I also need to provide an admin user a method of changing this value from within the application.

    So I created a 3rd table with a single record/row to hold the exchange rate, but I can't reference this with the forms in the application. I then created a module and put in a public variable, but how can I get this to hold a value when the user exits the application?

    It feels that this should be easy.



    Simon

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    but I can't reference this with the forms in the application
    why not? just add to the form recordsource or in an unbound control use the dlookup function

    but how can I get this to hold a value when the user exits the application?
    by saving it in a table - but this then begs the question, you have multiple users, do they all use the same exchange rate or is it in some way personal to them i.e. you want a USD conversion but users are all over the world using different currencies?

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    if the user exits the application then the global values are lost.

    if IN the app, you can always assign the global when the user opens the app.
    in module:
    Public gvExchangeRate

    when main menu opens
    Code:
    sub Form_load()
    
    gvExchangeRate = Dlookup("ExchangeRate]","table") end sub


    but to hold it in PC memory after the app closes, youd need an environment variable like: Environ("Username")
    or store in the Registry.
    SaveSetting "MyApp", "ExchangeRate", "Rate", 75

    then
    getRegistrySetting = GetSetting("MyApp", "ExchangeRate", "Rate")


  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    or you can store it in the front end properties as a property called 'exchange rate' - but your admin person will not be able to access that to change it. Seems to me a table is the only way.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,673
    Why can't the currency rate be read from currency table directly? Or are your linked tables available for users for editing (very bad practice!)?

    Another can of worms is the possibility, some user opens app before currency rate(s) for current day are entered.

    My advice is, hide Access Objects Pane from users, and set up startup form. Users have direct access to forms only.

    In back-end you must have a table with field for exchange rate(s) for one or several valutas, and a field for date. The table is linked to every front-end. The user who has right to enter exchange rates must have front-end with form, where he/she can enter current exchange rates for current day, and where he/she can confirm entered rates (confirming is allowed when all rates are entered). When rates are confirmed, current date is written into date field for every rate.

    Unless date in course table is current one, for all other forms data entry/editing must be disabled. So when someone opens app before current rates are entered, no data can be altered in app.

    All concversions must be done by code (form or form control events). The event reads rate from currency table and uses it in calculations. It also can be displayed on form(s) using unbound control and DLookup formula in it.

  6. #6
    Turncloud is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2013
    Posts
    22
    Thanks all for the replies. I'm back with the customer today and managed to resolve it with a DLookup as per ranman's post.

  7. #7
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Exchange rates float freely against one another, which means they are in constant fluctuation. So how will your table of Exchange rates stay current?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Exchange rate updation before Printing Report
    By iranbir in forum Reports
    Replies: 5
    Last Post: 01-24-2018, 05:28 AM
  2. Variable rate based upon a month
    By Lluewhyn in forum Queries
    Replies: 6
    Last Post: 07-07-2016, 02:26 PM
  3. Can't See Global Variable
    By CementCarver in forum Programming
    Replies: 12
    Last Post: 09-19-2013, 12:28 PM
  4. Exchange Rate Table for query
    By That_Guy in forum Queries
    Replies: 12
    Last Post: 10-15-2012, 07:58 AM
  5. Global variable
    By ramdandi in forum Queries
    Replies: 3
    Last Post: 12-18-2011, 01:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums