Results 1 to 6 of 6
  1. #1
    almontaser92 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2022
    Posts
    5

    Fill table fields according to the field name

    I have a table named "SourceTable" that contains a field for the employee number and a field for the field name and a field for the value of the field in the second column and another table with the name "tblEmpData" and I want to fill each field in it based on the value associated with its name in the first table
    Can this be done using code?
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    What a strange request

    Yes. I would use the source table as a recordset.
    Loop through the records building a sql string (probably two TBH) until the employeeID changes.
    When it changes execute the Insert/Update sql

    Rinse and repeat
    You could do one field at a time, but very inefficient, if easier to code.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    ???Confusing request??
    Perhaps you could describe what you are trying to achieve and why you decided on the approach you posted.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by orange View Post
    ???Confusing request??
    Perhaps you could describe what you are trying to achieve and why you decided on the approach you posted.
    Several replies and modified DB uploaded on crossposted site
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Now appears solved on the crossposted site
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 4
    Last Post: 03-09-2020, 01:42 AM
  2. Auto Fill Fields in a Form using a Combo field
    By jlindquist23 in forum Access
    Replies: 9
    Last Post: 03-14-2019, 10:55 AM
  3. auto fill fields based on another field
    By dbell in forum Forms
    Replies: 18
    Last Post: 05-26-2014, 01:46 PM
  4. Replies: 3
    Last Post: 03-07-2014, 10:39 AM
  5. Replies: 2
    Last Post: 02-25-2011, 03:56 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