473,395 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 12801
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.google.c om...
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*****@localhost.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*****@localhost.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.DefaultValue = Me!Field1
Me!Field2.DefaultValue = 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*****@localhost.not> schreef in bericht
news:Z5****************@nwrddc01.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.google.c om...
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
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...
1
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...
2
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...
2
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...
1
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...
12
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...
1
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...
2
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...
3
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.