Solved

How create new record when entering data in current record

Posted on 2013-12-31
2
457 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
Comment Utility
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
Comment Utility
You are correct.  Using the AfterUpdate event of the form is a much better way.  Thanks.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now