Solved

How have form "remember" data entry for certain fields for subsequent record entry

Posted on 2012-03-19
4
448 Views
Last Modified: 2012-03-19
Is there a way to have certain fields on a form "remember" the previous data entry from the previous record entered?

In other words, I have a form that is used to create records in a table.  But some of the fields on the form I want to have repeat the prior entry so the user doesn't have to key it again.

Can this be done?

--Steve
0
Comment
Question by:SteveL13
4 Comments
 
LVL 44

Expert Comment

by:GRayL
Comment Utility
In the new area, type ctl+' (apostrophe) to copy the data in the previous record into the current record.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
If you are entering records consecutively, without closing the form, you could use the AfterUpdate event of those controls, something like:

Private Sub txt_Field1_AfterUpdate

    me.txt_Field1.DefaultValue = me.txt_Field1

End Sub
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Be careful with the term "Previous Record"

Unless you app is somewhat secured, a user can easily "resort" the list, thus changing what was once the "Previous Record"

In any event, you can also use the button Wizard to Create code to "Copy" the current record and create a new record.

    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdCopy
    DoCmd.RunCommand acCmdRecordsGoToNew
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdPaste

Then clear out any field you did not want copied with something like this:
me.txtSomeValue1=""
me.txtSomeValue3=""


JeffCoachman
0
 
LVL 42

Expert Comment

by:dqmq
Comment Utility
There are many ways to accomplish that offering you different levels of control over what "previous" means and under what conditions you default a record to that value.

Let me propose one, which is fairly simple and gives you a fair amount of flexibilty:

In the form's after update event, save the old value(s) like this:

me.YourControlName.Tag = Me.YourControlName.Value


In the form's on current event, default to the saved value like this:
if me.newrecord and isnull(me.YourControlName.Value) then me.YourControlName.Value = me.YourControlName.Tag


ps.  If you don't like using the .tag property for that purpose, you can just as well use invisible fields on the form, variables that are global to the form, or other forms of session-scoped storage.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

7 Experts available now in Live!

Get 1:1 Help Now