Results 1 to 6 of 6
  1. #1
    baskey is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    5

    Record Creating Automatically

    HI ....
    I have a database that I would like to create records in a table. I have 1 table called employees and 1 called training linked together as a one to many in a table called Level.
    In the training table there is a field called "mandatory". When a new employee is added I would like it to create all records (blank) where "Mandatory =True". If anyone can help me I would be very very grateful....


    kind regards
    steveT_ Database.zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Could use INSERT SELECT sql action. Like:

    CurrentDb.Execute "INSERT INTO Level(EmpID, TrainingID) SELECT " & Me.tbxEmpID & " AS EmpID, TrainingID FROM Training WHERE Mandatory=True"
    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
    baskey is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    5

    HELP (please)

    Quote Originally Posted by June7 View Post
    Could use INSERT SELECT sql action. Like:

    CurrentDb.Execute "INSERT INTO Level(EmpID, TrainingID) SELECT " & Me.tbxEmpID & " AS EmpID, TrainingID FROM Training WHERE Mandatory=True"

    Many thanks for your advice June7
    I tried to enter this into a query
    INSERT INTO Level1(EmpID, TrainID) SELECT "Me.tbxEmpID & AS EmpID, TrainingID FROM Training WHERE Mandatory=True" but get error
    "number of query and destination fields are not the same"...
    Sorry I'm not to good with SQL !
    Any further help please ?
    cheers
    steve
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    What I showed is VBA code that executes an SQL action. The syntax is not correct for use in an Access query object.
    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.

  5. #5
    baskey is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    5
    Thanks June7....
    I setup a command buttone to run the following code

    Private Sub Command17_Click()
    CurrentDb.Execute "INSERT INTO Level1(EmpID, TrainID) SELECT " & Me.tbxEmpID & " AS EmpID, TrainingID "FROM Training WHERE Mandatory=True"
    End Sub

    but just get error saying module not found ! Apologies for not being to good at this...
    kind regards
    Steve

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    You show an extra " in front of FROM.
    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. Automatically Creating an Invoice
    By Kelsod in forum Access
    Replies: 8
    Last Post: 05-15-2013, 08:03 PM
  2. Replies: 3
    Last Post: 04-09-2013, 01:39 PM
  3. Replies: 11
    Last Post: 02-04-2013, 05:32 PM
  4. Creating a Record that automatically adds more records
    By fatimah25 in forum Database Design
    Replies: 5
    Last Post: 08-22-2012, 02:07 PM
  5. fields automatically filled in a new record
    By fabiobarreto10 in forum Forms
    Replies: 9
    Last Post: 04-09-2012, 05:18 PM

Tags for this Thread

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