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

how to add 1 minute based on previous record in same field in access

547 512MB
I have a table with datetimes in the following format:
12/08/2011 20:01:29.107 (date hr min sec 1/1000)

if my current record in row 1 is =
row 1 - 12/08/2011 20:01:29.107 (+ 1 minute then row 2 should become)
row 2 - 12/08/2011 20:01:30.107 when i double click inside row 2 if needed

In short, when i click in the next empty datetime field (timestart), then it must retrieve the previous datetime field (timestart) and add 1 minute to it.

The following code retrieve my previous record's datetime. How do i now modify it please?
Expand|Select|Wrap|Line Numbers
  1. TimeStart = DLookup("[Timestart]", "RaceEntry", "[RacEentryID]=" & [RaceEntryId] - 1)
Aug 13 '11 #1

✓ answered by NeoPa

It seems DateTime variables and values cannot handle fractions of a second. I suggest then, that you separate out the second fractions before the call and re-add them afterwards :
Expand|Select|Wrap|Line Numbers
  1. Dim strTime As String, strFraction As String
  2.  
  3. strTime = DLookup("[Timestart]", _
  4.                   "RaceEntry", _
  5.                   "[RaceEntryID]=" & [RaceEntryId] - 1)
  6. strFraction = Split(strTime, ".")(1)
  7. strTime = Split(strTime, ".")(0)
  8. TimeStart = Format(DateAdd("n", 1, strTime), "dd/mm/yyyy HH:nn:ss.") & _
  9.             strFraction

6 2973
NeoPa
32,556 Expert Mod 16PB
Use :
Expand|Select|Wrap|Line Numbers
  1. DateAdd("n", 1, YourDateTimeVal)
Aug 13 '11 #2
neelsfer
547 512MB
Hi Neopa
My problem
I have athletes starting one minute apart at a different starting location. I only have the starting time of the first person. Thereafter i have to add 1 minute to the starting time of the previous athlete, for the next one starting.

I have tried to incorporate your code with my existing code but no success so far.Any suggestions?
Expand|Select|Wrap|Line Numbers
  1. TimeStart = DateAdd("n", 1, DLookup("[Timestart]", "RaceEntry", "[RacEentryID]=" & [RaceEntryId] - 1))
I think my problem is worsen by the fact that the "timestart" field is a text field and not a date/time field.
Adezi was previously helping me with this to add the datetime up to 1/1000 of a second, with the following code:
Expand|Select|Wrap|Line Numbers
  1. GetLocalTime MyTime
  2. [Forms]![RaceSetupttF]![Rt_StartTTSF]![TimeStart] = Format$(MyTime.wDay, "00") & "/" & Format$(MyTime.wMonth, "00") & "/" & MyTime.wYear & _
  3.                                        " " & Format$(MyTime.wHour, "00") & ":" & Format$(MyTime.wMinute, "00") & ":" & _
  4.                                        Format$(MyTime.wSecond, "00") & "." & Format$(MyTime.wMilliseconds, "000")
Aug 13 '11 #3
NeoPa
32,556 Expert Mod 16PB
It seems DateTime variables and values cannot handle fractions of a second. I suggest then, that you separate out the second fractions before the call and re-add them afterwards :
Expand|Select|Wrap|Line Numbers
  1. Dim strTime As String, strFraction As String
  2.  
  3. strTime = DLookup("[Timestart]", _
  4.                   "RaceEntry", _
  5.                   "[RaceEntryID]=" & [RaceEntryId] - 1)
  6. strFraction = Split(strTime, ".")(1)
  7. strTime = Split(strTime, ".")(0)
  8. TimeStart = Format(DateAdd("n", 1, strTime), "dd/mm/yyyy HH:nn:ss.") & _
  9.             strFraction
Aug 13 '11 #4
neelsfer
547 512MB
Thx Neopa, it works great!
Aug 13 '11 #5
NeoPa
32,556 Expert Mod 16PB
Good to hear Neels :-)
Aug 13 '11 #6
NeoPa
32,556 Expert Mod 16PB
A new but related question has been split off into its own thread and can be found at Why does my Code Work - but Only Sometimes.
Nov 18 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Derek Cooper | last post by:
I hope you can help me. I posted this in the microsoft sql server newsgroup a few days ago and got no response so I thought I'd try here. If I can provide any clarification I'll be glad to do so....
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...
4
by: | last post by:
Something really common I'm sure and I'm surprised it's not just a field property option. The previous record's field value can be retrieved and copied into the current corresponding field by...
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: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
7
by: ivijayan | last post by:
i need help in developing macros in MS Access 2003. based on the data in field X in a previous record, i have to prompt the user to change the value of X in the prevous record before entering any new...
3
by: Neil99 | last post by:
I have a table that is updated daily withdocument information. 1 of the fields is a document code and another is a page count. Each document type has an expected page count. I would like to use an...
16
by: zoeb | last post by:
Hi, I am a complete novice to Access VBA and looking for some help to select a record. I am looking to perform an operation on the previous record - i.e. adding a new blank field, and then...
4
by: falconerlf | last post by:
In crystal reports when I write a formula I can state a condition of say if the current field is blank, then print the content of the same field but from the previous record. The function is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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
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...

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.