Results 1 to 3 of 3
  1. #1
    whittssg is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    2

    Access Web Database - Create new record inside for each record loop

    Hello,

    I am trying to create several new records based on records in another table using the for each record loop in a Data Macro (After insert) but i keep getting this error:


    CreateRecord cannot be used inside of a ForEachRecord

    I read this is a design limitation of the web database but i was wondering if there was a workaround.

    I basically have 3 tables.

    Projects
    Questions
    Projects_to_questions

    When a new project is added it is supposed to create an entry in the projects_to_questions table for each question in the questions table linked to the project. The user then fills in some extra fields for each question.

    So is there another way to make Access auto create these entries based on the questions in the questions table?

    Thanks,

  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,892
    Maybe an INSERT SELECT sql. Essentially, the process is Insert into table records Selected from another table. http://www.w3schools.com/sql/sql_insert_into_select.asp

    The complication is dynamically referencing the PK/FK project ID and populating that into the new records. Perhaps follow with an UPDATE sql to fill the empty FK ID field.

    I can do this easily in VBA, I don't know macros well enough to guide.
    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
    whittssg is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    2
    Thanks for the reply.. I was actually looking for a way to do it without using any VB.
    I found a way in the end (workaround) which involved using the for each record action to update a temp column in the questions table with the record id of the project then i added a action on the questions table that fired when it was modified to create a new question based off the temp column data and the questions id.

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

Similar Threads

  1. Create Record Database Help
    By charlesh in forum Access
    Replies: 67
    Last Post: 10-03-2013, 11:55 AM
  2. Replies: 0
    Last Post: 08-23-2013, 05:46 PM
  3. Replies: 12
    Last Post: 10-27-2012, 05:44 AM
  4. Replies: 5
    Last Post: 08-21-2012, 12:30 PM
  5. Replies: 22
    Last Post: 06-12-2012, 10:02 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