473,386 Members | 1,754 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,386 software developers and data experts.

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 3457
Users can filter or sort forms at will, so the only way to get the "previous
record" would be to programmatically 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**********************************@j20g2000 hsi.googlegroups.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...@SeeSig.Invalidwrote:
Users can filter or sort forms at will, so the only way to get the "previous
record" would be to programmatically 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**********************************@j20g2000 hsi.googlegroups.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**********************************@m34g2000 hsf.googlegroups.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...@SeeSig.Invalidwrote:
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**********************************@m34g2000 hsf.googlegroups.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...only 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","TableName","ID < " & ME.ID)
Me.LastValue = Dlookup("FieldName","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","TableName","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,is 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.comwrote:
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...only 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","TableName","ID < " & ME.ID)
* * * * Me.LastValue = Dlookup("FieldName","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","TableName","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=yygjwDAijVE
Jan 7 '08 #7
thread wrote:
thank you for the quick repaly,it gave me some direction,now,is 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("ID","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
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...
5
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...
1
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...
9
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...
0
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...
8
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. ...
1
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...
7
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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,...

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.