Results 1 to 3 of 3
  1. #1
    gelabelle is offline Novice
    Windows 8 Access 2007
    Join Date
    Aug 2015
    Posts
    1

    Functions


    Hi

    How can I take the value from a field in a table and make it a Function

    Example: I have a table named "Percentagetbl". Inside the table I have a numeric field name "Underground"
    I wish to create a Function which will contain the value of the field (eg. .2)

    Once the Function is created I can then use that Fundtion name in any of my queries.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    A field cannot be 'made into a function' - a function can pull data from a table. If table has multiple records, there must be some criteria provided that will identify which record. Which record should this value come from? What is the determining circumstances and criteria?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,811
    Your post makes more sense to me if I think in terms of built-in functions or custom expressions - otherwise, not much.
    If your table only has one record in it but the value of 'Underground' can change, you can use DLookup to retrieve it. If you want to use this in a query as a custom function, you'd write something like
    Code:
    Function GetUnderground() as Integer  [or Long, or String, or whatever]
        GetUnderground = DLookup("Percentagetbl","Underground")
    End Function
    and call it from your query. If there is more than one record in the table, you cannot do this as written. But if you're looking for records to be returned by other queries and your data is that simple, why not just create a query that returns 2 (i.e. the Underground value) and link that field to other tables in your queries?

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

Similar Threads

  1. Global Variables?
    By futurezach in forum Reports
    Replies: 4
    Last Post: 06-20-2013, 03:45 PM
  2. Three variables for Criteria
    By lugnutmonkey in forum Queries
    Replies: 1
    Last Post: 01-30-2013, 11:52 AM
  3. VBA variables in SQL
    By compooper in forum Programming
    Replies: 3
    Last Post: 07-06-2011, 11:04 AM
  4. VBA in variables
    By smikkelsen in forum Access
    Replies: 3
    Last Post: 11-12-2010, 03:14 PM
  5. sql in vb variables
    By emilylu3 in forum Programming
    Replies: 3
    Last Post: 03-04-2006, 01:26 PM

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