Solved

How create new record when entering data in current record

Posted on 2013-12-31
2
463 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Setting a recordset out of a parameter query 12 28
default combobox value 12 17
Run an action on recently added records to a table 13 57
Access/Visual Basic Question 3 23
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

791 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