473,750 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy a fields Value

When entering a record in a form, I would like a value in a field of
the previous record to be entered automatically into a different field
of the current record. Which way should I go? Is it also possible to
do this based on criteria from the previous record?
Nov 12 '05 #1
4 12841
First, let me point out that the terms "next" and "previous" can be
misleading in relational database. By definition, records in a relational
table are unordered, and you cause them to be ordered by specifying sort
fields in a query (which is the same as an ORDER BY clause in SQL).

That said, assuming that you are specifying an order during data entry that
will be the order you obtain by sorting on output, then it is relatively
easy, in VBA code, to define form-level variables into which you save the
values of the Form's Controls in the AfterUpdate event of the Form. You can
then put VBA code in the OnCurrent event of a new record to use those
variables both to set Controls in the new Record and as criteria in
conditional VBA statements such as IF ... THEN ....

Even if the records are not being entered in order, but you can identify
what the "previous" record should be (by a field value, such as an Order
Number, Customer Number, or a combination of field values), you can write
VBA code to read the previous record from the table, and obtain its values.

For a "semi-automatic" approach, you can simply use Ctrl plus the
single-quote, which will fill the Control with the value from the
previously-entered Record.

Larry Linson
Microsoft Access MVP

"Gene" <hr*****@yahoo. com> wrote in message
news:47******** *************** ***@posting.goo gle.com...
When entering a record in a form, I would like a value in a field of
the previous record to be entered automatically into a different field
of the current record. Which way should I go? Is it also possible to
do this based on criteria from the previous record?

Nov 12 '05 #2
Tym
On Mon, 29 Dec 2003 18:10:01 GMT, "Larry Linson"
<bo*****@localh ost.not> wrote:
For a "semi-automatic" approach, you can simply use Ctrl plus the
single-quote, which will fill the Control with the value from the
previously-entered Record.


....and this keyboard shortcut is documented *where* ? :-)
Nov 12 '05 #3
"Tym" <no*****@ictis. net> wrote in message
news:3f******** ******@169.100. 100.5...
On Mon, 29 Dec 2003 18:10:01 GMT, "Larry Linson"
<bo*****@localh ost.not> wrote:
For a "semi-automatic" approach, you can simply use Ctrl plus the
single-quote, which will fill the Control with the value from the
previously-entered Record.


...and this keyboard shortcut is documented *where* ? :-)


Microsoft Access Help -> Keyboard Shortcuts
Nov 12 '05 #4
Gene,
In addition to Larry's remarks an approach that I learned from postings here:

You can use ANY field and code in the the field's afterupdate-event something like:
Me!Field1.Defau ltValue = Me!Field1
Me!Field2.Defau ltValue = Me!Field2
This results in ANY new entered value 'carried-on' to the next record.

I use this for quick data-entry in one of my apps for different UserID's and WorkID's
UserID and WorkID are 'carried on' and don't need to be entered for new records.
After any new input for UserID or WorkID the new ID is 'carried-on'.

--
Hope this helps
Arno R

"Larry Linson" <bo*****@localh ost.not> schreef in bericht
news:Z5******** ********@nwrddc 01.gnilink.net. ..
First, let me point out that the terms "next" and "previous" can be
misleading in relational database. By definition, records in a relational
table are unordered, and you cause them to be ordered by specifying sort
fields in a query (which is the same as an ORDER BY clause in SQL).

That said, assuming that you are specifying an order during data entry that
will be the order you obtain by sorting on output, then it is relatively
easy, in VBA code, to define form-level variables into which you save the
values of the Form's Controls in the AfterUpdate event of the Form. You can
then put VBA code in the OnCurrent event of a new record to use those
variables both to set Controls in the new Record and as criteria in
conditional VBA statements such as IF ... THEN ....

Even if the records are not being entered in order, but you can identify
what the "previous" record should be (by a field value, such as an Order
Number, Customer Number, or a combination of field values), you can write
VBA code to read the previous record from the table, and obtain its values.

For a "semi-automatic" approach, you can simply use Ctrl plus the
single-quote, which will fill the Control with the value from the
previously-entered Record.

Larry Linson
Microsoft Access MVP

"Gene" <hr*****@yahoo. com> wrote in message
news:47******** *************** ***@posting.goo gle.com...
When entering a record in a form, I would like a value in a field of
the previous record to be entered automatically into a different field
of the current record. Which way should I go? Is it also possible to
do this based on criteria from the previous record?


Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1642
by: Russell Shaw | last post by:
Hi, How do i easily assign one struct to another of a different type? struct Object object = allocate_object(); struct Widget widget = (struct Widget)object; /* doesn't work */ struct Widget is bigger than struct Object.
1
1266
by: Woody Splawn | last post by:
I have a number of fields on a form in a certain solution. In another solution with a similar form I need to have these same fields. Do I need to create them again from scratch or will it work ok to copy and past from one form in one solution to another form in another solution?
2
2675
by: Martin Ortiz | last post by:
Ugh.... All classes are copy by reference, even if you use "ByVal" and NOT "ByRef" it's still a copy by reference. Of course, as a consequence, if you change any values of the object you passed in, the original object is affected. I expect this with arrays, but not with single objects being passed "ByVal" to functions.... Is there a sane to get "ByVal" passing of parameters? (copying fields is not
2
2728
by: Shawn Yates | last post by:
I have a form with two subforms on it which are both continous forms. The subform on the left shows the tasks that the employee was assigned to accomplish (each as a seperate record) while the one on the right is where they put what tasks they actually did. It is important that I keep the assigned tasks unmodified because we eventually will be looking at the difference between assigned and accomplished tasks. I have a button on each task...
1
4306
by: chris | last post by:
I'm not sure this is even feasible. What I want to do is create a command button. When this command button is pressed, it taes field values and puts them into text format. I think I know how to do this part thru code. Then I want to copy this text to the clipboard so that I can paste it into a memo field. This is the part I need help with. I will create the text by the following method on the On Click Event of the command button:
12
4055
chunk1978
by: chunk1978 | last post by:
hi there... i'd like to know if it's possible to copy a selected file's name (value?) and insert it into a basic text field thru an onchange event handler... here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Untitled...
1
2057
by: lrw0831 | last post by:
I have the main form where employees enter "issues". Some issues have fields that are the same. My fields are Issue ID (auto) Product Entered BY Issue Type Priority Request from Status Assigned to
2
2834
by: banderson | last post by:
Hello Bytes, I am having trouble copying a value from an open record in a recordset into a form. I have a form frmOutreachReferral that is filled in after a Site Visit has been performed and it is determined that the site needs a follow up visit. A Site Visit is entered into frmSV and is based on tblOutreachAdmin with its primary key (autonumber) field called OutreachID. If a referral is needed, you click on a button to open...
3
3988
by: jbrumbau | last post by:
Hello, I am trying to refer to fields on a given form from the form query's recordset, essentially from the following commands: Dim frm As Form 'Refers to the current form Dim tagName As String 'Refers to the field in the form's recordset (not a control on the form) ... frm.Fields(tagName).Value 'This gives Error 2465
0
9001
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6808
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.