473,804 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i get previous record on a form

Hi all i need to build progression calculator for a record and for
this i need to have the possiblity to get the information for the
previous record.
is it posible to do it or i will need to use recordset for this?
Jan 7 '08 #1
7 3480
Users can filter or sort forms at will, so the only way to get the "previous
record" would be to programmaticall y locate the current record in the form's
RecordsetClone, and MovePrevious.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"thread" <ya******@gmail .comwrote in message
news:18******** *************** ***********@j20 g2000hsi.google groups.com...
Hi all i need to build progression calculator for a record and for
this i need to have the possiblity to get the information for the
previous record.
is it posible to do it or i will need to use recordset for this?
Jan 7 '08 #2
is there a way to present on the screen previous record?
for all records
On 7 י*ואר, 13:12, "Allen Browne" <AllenBro...@Se eSig.Invalidwro te:
Users can filter or sort forms at will, so the only way to get the "previous
record" would be to programmaticall y locate the current record in the form's
RecordsetClone, and MovePrevious.

--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"thread" <yaniv...@gmail .comwrote in message

news:18******** *************** ***********@j20 g2000hsi.google groups.com...
Hi all i need to build progression calculator for a record and for
this i need to have the possiblity to get the information for the
previous record.
is it posible to do it or i will need to use recordset for this?-הסתר טקסט מצוטט-

-הראה טקסט מצוטט-
Jan 7 '08 #3
If you set the Default View of the form to:
Continuous Form
you can see more than one record at a time.
No code needed.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"thread" <ya******@gmail .comwrote in message
news:9c******** *************** ***********@m34 g2000hsf.google groups.com...
is there a way to present on the screen previous record?
for all records

Jan 7 '08 #4
hi,
thank you for you quick replay,the issue is that i need to use the
previous record to make a progression calculation on the currect
for example
a 100
b 200
c 300
so on b i would like to have (b-a
c would be c-b
and so on,is this posible?

On 7 י*ואר, 13:41, "Allen Browne" <AllenBro...@Se eSig.Invalidwro te:
If you set the Default View of the form to:
* * Continuous Form
you can see more than one record at a time.
No code needed.

--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"thread" <yaniv...@gmail .comwrote in message

news:9c******** *************** ***********@m34 g2000hsf.google groups.com...
is there a way to present on the screen previous record?
for all records
Jan 7 '08 #5
thread wrote:
hi,
thank you for you quick replay,the issue is that i need to use the
previous record to make a progression calculation on the currect
for example
a 100
b 200
c 300
so on b i would like to have (b-a
c would be c-b
and so on,is this posible?
In your case, for speed issues, I'd suggest you store that value in the
record to a field...call it LastValue...onl y if the current value will
never change for this record. If the value changes you'd need to update
the entire table and this suggestion would be better left ignored.

I'd suggest you have an autonumber in the table. As Alan noted,
filtering and sorting could throw you off.

Is the value will always be static then:
You could then do something like this in some event on the form, maybe
the BeforeUpdate event of the form.
Dim LastID As Long
LastID = DMax("ID","Tabl eName","ID < " & ME.ID)
Me.LastValue = Dlookup("FieldN ame","TableName ","Id = " & LastID)

If the values will/can change then
Use a query and make the field calculated. You could create a new query
with two columns; ID and LastID. ID would be the autonumber of the
table, LastID using something like
LastID : DMax("ID","Tabl eName","ID < " & [ID])

Linking your table to this query in another query you could then get the
last value to use the Dlookup to get the LastValue. From there you can
do your subtraction.

Easy
http://www.youtube.com/watch?v=yygjwDAijVE

Jan 7 '08 #6
thank you for the quick repaly,it gave me some direction,now,i s it
posible based on the result to preserve the previsous result or to get
the current one
for example
a 100
b 150
c 300
result will be

100 a
iif b-a<60 then 100 else current

meaning:
100 b
300 c

On 7 י*ואר, 14:47, Salad <o...@vinegar.c omwrote:
thread wrote:
hi,
thank you for you quick replay,the issue is that i need to use the
previous record to make a progression calculation on the currect
for example
a 100
b 200
c 300
so on b i would like to have *(b-a
c would be c-b
and so on,is this posible?

In your case, for speed issues, I'd suggest you store that value in the
record to a field...call it LastValue...onl y if the current value will
never change for this record. *If the value changes you'd need to update
the entire table and this suggestion would be better left ignored.

I'd suggest you have an autonumber in the table. *As Alan noted,
filtering and sorting could throw you off.

Is the value will always be static then:
You could then do something like this in some event on the form, maybe
the BeforeUpdate event of the form.
* * * * Dim LastID As Long
* * * * LastID = DMax("ID","Tabl eName","ID < " & ME.ID)
* * * * Me.LastValue = Dlookup("FieldN ame","TableName ","Id = " & LastID)

If the values will/can change then
Use a query and make the field calculated. *You could create a new query
with two columns; ID and LastID. ID would be the autonumber of the
table, LastID using something like
* * * * LastID : DMax("ID","Tabl eName","ID < " & [ID])

Linking your table to this query in another query you could then get the
last value to use the Dlookup to get the LastValue. *From there you can
do your subtraction.

Easyhttp://www.youtube.com/watch?v=yygjwDA ijVE
Jan 7 '08 #7
thread wrote:
thank you for the quick repaly,it gave me some direction,now,i s it
posible based on the result to preserve the previsous result or to get
the current one
for example
a 100
b 150
c 300
result will be

100 a
iif b-a<60 then 100 else current

meaning:
100 b
300 c
I don't know as I'm not sure I understand the question. You could try
this out. Create a new database/mdb. Create a new table, called
Table1. Add 2 fields; ID (autonumber), Score (Number)

Add 5 records to table1. My values for Score are 100, 150, 300, 450, 500.

Create 2 queries; (Query/New/Design (close on Add Tables). From the
menu select View/SQL. Copy/paste the following queries and name them as
I did. Save them.

BTW, the first record will have no previous value.

QueryName = Table1Previous
SELECT Table1.ID, Table1.Score AS CurrentScore,
CLng(NZ(DMax("I D","Table1", "ID <" & [ID]),0)) AS PreviousID
FROM Table1;

QueryName = Table1Final
SELECT Table1Previous. ID, Table1Previous. CurrentScore,
NZ([Table1_1]![Score],0) AS PreviousScore,
IIf([CurrentScore]-NZ([Table1_1]![Score],0)<60,NZ([Table1_1]![Score],0),[CurrentScore])
AS CalcedScore, [CurrentScore]-NZ([Table1_1]![Score],0) AS Expr1
FROM Table1Previous LEFT JOIN Table1 AS Table1_1 ON
Table1Previous. PreviousID = Table1_1.ID;

Now run Table1Final. Review the values in the columns and see if does
what you need.

White Wedding
http://www.youtube.com/watch?v=C0YGrj2A0Q4
Jan 8 '08 #8

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

Similar topics

1
2220
by: ubmc | last post by:
Revised form layout by dragging/dropping fields from field list and deleting unwanted fields. However, unable to go to next existing record or return to previous existing record, but can add new record. Error message received when attempting to go to next or previous existing record: "The value you entered isn't valid for this field."
5
2227
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table (tbl_MainRegister) providing a unique identifier for documents and a means for identifying the docuement type. There are then 4 additional tables (tbl_Meetings, tbl_Documents, tbl_Project, tbl_Correspondence) which store the document details.
1
1904
by: JRT | last post by:
I have a continuous form with 3 comboxes, combo1, combo2 combo3. The choices in combo2 are dtermined the what is selected in combo1 by using a where = combo1 statement. The combo is refreshed with code, i.e. . The combo are freshed with code on after update of previous combo. SO combo1 after update might be me.combo2.requery. It works well to fill in the combo box with the choices, but problem is when I go down to the next record in...
9
6755
by: Karl Roes | last post by:
Hi All, I would like some advice on Next / Previous record buttons. I have a main form for the client, and a continuous subform listing client transactions. If I open one of these transactions ( dblclick ) in say 'frmtransaction', I would like to scroll forward and backward through the transactions as they appear on the continuous subform without actually having to close 'frmtransaction' and go back to the subform.
0
2701
by: KelHemp | last post by:
Greetings, I've been using this site for lots of access help in the past, and it's very helpful! I have a new complexity for you all. Reworking a form to record 70-80 years of oil production on multiple leases, which have multiple wells within them. Most wells can fit on one printed page (one record), but in the case of overspill, we want to do the following: -Move to a new record and auto fill the LeaseName, LeaseNumber, Operator,...
8
3197
by: Jeff | last post by:
A client wants a press of the Enter key in a field on a continuous form to grab the value of that field from the previous record. But if they have typed a value and then hit Enter it shouldn't. I have tried a few ways but the main problem is that after typing a value and hitting Enter it still grabs the value from the previous record, trashing the value they just typed. Any ideas from you lateral thinkers.
1
2818
by: neelesh kumar | last post by:
i have 4 optionbuttons in my form. if i select 1st optionbutton traineeans.value=1,2ndbutton traineeans.value=2...like that.If he didnt select anyone traoneeans.value=0. one commandbutton is there named previous unaswered,and other command button is next. if i click that button previousunanswwered i want to go to previous record where traineee ans.value=0. DoCmd.GoToRecord , , acprevious is going to the previous record.but i want to go...
7
3429
by: FNA access | last post by:
I have a mainform that has a subform in the detail section and a subform in the footer section.(Both subforms are in datasheet view) When I click the navigation button to create a new record on the mainform. My subform in the detail section goes blank (this is what I want) but my subform in the footer section appears to have the data from the previous record displayed. When you click on the subform the data dissapears and displays blank. If...
1
2128
by: bkberg05 | last post by:
Hi -I have a form which contains a sub-form. The sub-form is tied to the main form by a shared field called Project_ID. The main form has one record per Project. The sub-form has many records per Project. When I'm adding Project records and go to a new record, the sub-form has no data in it. But then as soon as I type any data into the first field on the main form (after I type in the first character), the sub-form appears to populate...
0
10568
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
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7613
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
6847
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
5516
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
4292
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
2988
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.