[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How create new record when entering data in current record

Posted on 2013-12-31
2
Medium Priority
?
474 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 earned 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

650 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