Results 1 to 2 of 2
  1. #1
    datsyuk is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2012
    Posts
    7

    Creating new entries using macro's & query's

    Hi all I'm not entirely sure if what I'm about to describe is possible. I have an input Table with most importantly: skills, dates, and hours as fields. Basically for a certain skill a given number of hours are needed for each month. However, in the current table not all months have hour entries for all skills. What I would like to do is create records for all date/skill combo's with hour value 0 if there is no record that exists.



    So:

    Skills......Dates......Hours
    -----entered data-----
    ...............................

    //append this onto it
    --remaining combos--0
    .............................0
    ...

    My thoughts for how to go about this is some sort of query against the Master Tables of Skills (and possibly a master Calendar Table). For all records that are unmatched I will need to create a new one in the Labor table w/ value 0 for hours. I am not sure whether I am on the right track for this; if there is a simpler or better way to go about it. I also am not sure how to go about querying for all possible combinations of Skill/Month or creating records with the given value 0 for hours.

    Thoughts?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Could get complicated. Try:

    First create a dataset that will have record for each month/year. If there is at least one record for each month/year in the Labor table, then that will serve. Query1:
    SELECT DISTINCT Format(Dates, "mm01yyyy") AS MoYr FROM Labor;

    Then use that query in a query with the master skills table. This will result in a dataset with records for every combination of skill and month/year. Query2:
    SELECT MoYr, Skills FROM Query1, SkillsMaster;

    Query3 of the Labor table:
    SELECT DISTINCT Skills, Format(Dates, "mm01yyyy") As MoYr FROM Labor;

    Join the last two queries on the Skills and MoYr Fields, jointype 'Show all records from Query2...' Records where the fields from Query3 show null means that skill and MoYr not in Labor table.

    Does this need to be done for each employee? That adds more complication.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-05-2012, 02:34 AM
  2. creating a validation macro on a form.
    By MJRobinson21987 in forum Forms
    Replies: 4
    Last Post: 08-17-2011, 09:52 AM
  3. Problem creating hyperlink to a sub macro
    By AccessOAP in forum Programming
    Replies: 2
    Last Post: 08-15-2011, 08:05 AM
  4. Creating Macro from Module
    By Harley Guy in forum Modules
    Replies: 1
    Last Post: 11-08-2010, 07:44 AM
  5. Subform creating new unwanted entries
    By Rpatrick in forum Access
    Replies: 1
    Last Post: 08-14-2009, 03:08 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