Results 1 to 2 of 2
  1. #1
    kelkan is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    26

    open a form to a new record for a specific employee

    I have 3 tables: tblEmployees, tblCourses, and tblTraining. I have a form to schedule training for employees called FORMSCHEDULE that is based on a query called QUERYSCHEDULECLASSES. The form has the following fields:
    TRAININGID (PK in tblTraining)
    EMPLOYEEID (FK in tblTraining)
    EMPLOYEENAME (calculated last and first name field from tblEmployees)
    COURSEID (FK in tblTraining)
    cboCourse (combo field to tblCourses)

    I want to open the form to a new record in tblTraining for a specific employee in another form. Right now, I have a command button on the other form (frmEmployeeList) that opens this form. I have the query for FORMSCHEDULE (QUERYSCHEDULE CLASSES) criteria set under EMPLOYEEID like this: [EMPLOYEEID]=[forms]![FrmEmployeeList]![EMPLOYEEID]

    I can get the form to open to the specific employee I want, but it shows an existing training class already entered in tblTraining.


    I tried to set TRAININGID criteria to Is Null but I get nothing in any field on the form (FORMSCHEDULE).

    How do I create a new record in tblTraining for a specific employee and open the form to a new TRAININGID for that specific employee?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You want to open Training form to a new record and populate the EmployeeID of that new record?

    Have you considered a form/subform arrangement instead?

    This is one reason I don't use parameterized queries, too restrictive. Instead, I use WHERE CONDITION of DoCmd.OpenForm.

    Behind button to open existing record:
    DoCmd.OpenForm "formname", , , "EmployeeID=" & Me.EmployeeID

    Behind button to open new record, use OpenArgs to pass EmployeeID:
    DoCmd.OpenForm "formname", , , , acFormAdd, , Me.EmployeeID

    Then code in training form Current event:
    If Me.NewRecord Then Me.EmployeeID = Me.OpenArgs
    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: 6
    Last Post: 11-13-2012, 04:29 PM
  2. Open form on specific record
    By iky123 in forum Forms
    Replies: 1
    Last Post: 04-11-2012, 09:56 AM
  3. Replies: 11
    Last Post: 02-01-2012, 01:14 AM
  4. Open form to specific record
    By Two Gun in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 10:00 AM
  5. Open Form to Specific Record
    By batowl in forum Forms
    Replies: 1
    Last Post: 04-08-2011, 10:10 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