Results 1 to 4 of 4
  1. #1
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163

    How to write access VLOOKUP formulas as field default value based on another table

    For example, I have two Access tables (backend database): TableUser and TableWorkingHours



    For TableUser, Username is unique.

    I understand that I should not have FirstName and LastName in TableWorkingHours. For some reasons, I don't feel comfortable writing join SQL statement in Visual Studio C# frontend application (not an IT professional). But this is not the question.

    My question is: Since I have already had FirstName and LastName in TableWorkingHours, and I prefer not to remove these two fields. So I am looking into Access field default value, and would like to write a VLOOKUP formulas for FirstName and LastName.

    How should I write the formulas?

    Thanks.
    Attached Thumbnails Attached Thumbnails Access Vlook.JPG  

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    Access does not have a VLookup function (in a properly designed db it wouldn't be necessary). Perhaps explain what it is you are trying to do. If it is to get at the records in the hours table, you don't even need to join that table to the users table because as you've already pointed out, you are repeating data in tables (not proper). If you also need the status values, then you need to join.

    If this is about using expressions in a table then there is a very short list of expressions that can be used in a table. This approach is ill advised - users should be interacting with data by using forms/reports - not directly in tables. Also, data calculated in table fields is subject to being orphaned or out of sync when other records are deleted/altered.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    VAer is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2016
    Location
    USA
    Posts
    163
    Quote Originally Posted by Micron View Post
    Access does not have a VLookup function (in a properly designed db it wouldn't be necessary). Perhaps explain what it is you are trying to do. If it is to get at the records in the hours table, you don't even need to join that table to the users table because as you've already pointed out, you are repeating data in tables (not proper). If you also need the status values, then you need to join.

    If this is about using expressions in a table then there is a very short list of expressions that can be used in a table. This approach is ill advised - users should be interacting with data by using forms/reports - not directly in tables. Also, data calculated in table fields is subject to being orphaned or out of sync when other records are deleted/altered.
    Ok, I think I do have to completely change front end application query to join statement.

    Thanks.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Note that "Date" is a reserved word in Access and a built in function. Maybe use "WorkingDate" instead (no spaces).

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

Similar Threads

  1. Replies: 21
    Last Post: 03-28-2017, 02:04 AM
  2. Vlookup & Match on a table in microsoft access
    By forestgump in forum Queries
    Replies: 4
    Last Post: 09-19-2014, 06:58 PM
  3. Replies: 4
    Last Post: 12-17-2012, 01:21 PM
  4. Replies: 2
    Last Post: 10-09-2012, 03:20 PM
  5. ODBC table read to blank Access table write
    By dibblejon in forum Access
    Replies: 2
    Last Post: 03-10-2010, 08:39 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