Solved

How create new record when entering data in current record

Posted on 2013-12-31
2
471 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

695 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