Dynamically updating an unbound control from data stored in a table

Posted on 2011-04-29
Last Modified: 2013-11-28
I have a MS Access 2007 database that is used to refresh off-line tables from an external data source. I have a utility table where I am storing the last updated date. I would like to query that data dynamically when my form opens to update an unbound control.

I don’t have much experience with VBA, but am guessing this would be a pretty easy tasks.

The control name is: txLastUp
The from name is: frmUtility
The SQL to pull the value back via a query is: SELECT utlValue FROM tblUtility WHERE (((utlMod)='frmUtility') AND ((utlCode)='LASTUP'));

Thank you in advance,
Question by:mmcrain
    LVL 77

    Accepted Solution

    You can store the sql as a saved query and you can then retrieve the value easily.

    me.txLastUp= dlookup("utlvalue", "savedqueryname")

    It sounds from your description that this code can go in the Form_Load event procedure.

    Alternatively, instead of saving the query,  you can just use a qualified dlookup()

    me.txLastUp= dlookup("utlvalue", "tblUtility", "utlMod='frmUtility' AND utlCode='LASTUP'")

    Author Comment

    That worked great. Thank you.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now