Solved

How create new record when entering data in current record

Posted on 2013-12-31
2
462 Views
Last Modified: 2013-12-31
Using a form in datasheet view mode, I have a field named "NextDueDate". This is a date field, short date format.  When the user has made an entry in this field I want a new record to automatically be created with the same date just entered populated to a field named "DueDate" in the new record.

What would the afterupdate event be for the field "NextDueDate" on the form?

--Steve
0
Comment
Question by:SteveL13
2 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39748176
Rather than using the AfterUpdate event of that control, I'd consider using the AfterUpdate even of the form.  That way, the user can enter that date and move to the next control without automatically creating that record.  When the user finally decides to save this record, then you could create the new record, giving the user the opportunity to change their mind or even cancel that update.

There are a couple of ways to do this.  You could write a SQL insert query using syntax similar to:

strSQL = "INSERT INTO yourTable (Field1, DueDate, field3) " _
            & "Values (1, #" & me.NextDueDate & "#, 2)"
currentdb.execute strsql, dbfailonerror

or you could create a recordset from your forms recordset

set rs = me.recordsetclone
With rs
    .addnew
    !Field1 = 1
    !DueDate = me.NextDueDate
    !Field3 = 2
    .Upate
end with
set rs = nothing
0
 

Author Comment

by:SteveL13
ID: 39748200
You are correct.  Using the AfterUpdate event of the form is a much better way.  Thanks.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question