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

How to add one minute intervals to copied time

1
Hi Everyone,
I am an access newbie and have been having a bit of trouble trying to get this code right.

I have one minute intervals between records, so I would like to have the start time from one record be transferred to the start time of the next record plus one minute.

I have been using the dlookup function to transfer all the information I need from one record to the next but cant seem to get the code right on how to add on the minute.

My code so far is:

Expand|Select|Wrap|Line Numbers
  1. Dim ID As Long
  2.  
  3. ID = DMax("Focal_ID", "OnshoreFocal")
  4. DoCmd.GoToRecord , , acNewRec
  5.  
  6. Date = DLookup("Date", "OnshoreFocal", "Focal_ID=" & ID)
  7. Start = DLookup("Start", "OnshoreFocal", "Focal_ID=" & ID)
  8. Format = DateAdd ("n",1,Start)
When I use the DateAdd code next to add on the minute I get an error.

All help greatly appreciated
TIA
Cath
May 21 '18 #1
2 744
PhilOfWalton
1,430 Expert 1GB
Hi Cath, welcome to Bytes.

I'm not surprised you are struggling.

At the top of every module, you should have
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
The Option Explicit ensures that you declare every variable in your code. (The only one that you have declared is ID)

Try to make all your variables have a meaningful name. ID tells you nothing.

Have a look at Reserved words. Both "Date" & "Format" are reserved words.

I am assuming that Start is a Date/time field.

I think you will need something like
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Sub NewTime
  5.     Dim NextStart as Date
  6.  
  7.     NextStart = DateAdd("n",1, DMax("Start","OnshoreFocal"))
  8.     DoCmd.GoToRecord , , acNewRec
  9.     Start = NextStart
  10. End Sub
  11.  
The last line probably won't work. It all depends on what triggers the Sub to run

Phil
May 21 '18 #2
NeoPa
32,556 Expert Mod 16PB
Also, when posting code and reporting a problem, please remember to post all the code that's relevant as well as what the error actually is that's been reported to you.
May 21 '18 #3

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

Similar topics

4
by: Hans | last post by:
Hi there, I need to create a list (diary style) of times in a day. I can do this with normal "metricated" break-up of the hours, but need to display the actual time. I have a "Starting time" and...
4
by: Rick Barr | last post by:
I'm trying to build a tee-time reservation page, and want to display all the available tee times on one page for a particular date. I simply want to list the times out in 10-minute intervals,...
5
by: Marcus | last post by:
Hi, was wondering if anyone knows a good algo for rounding time to a desired interval. For instance, I have data set that is timestamped in second resolution and I need to modify that data to be...
2
by: bb02 | last post by:
I have a login audit table that has a LoginDateTime and a LogoutDateTime. I am wanting to count the number of users whose datetime range falls between 15 minute intervals each day. For example: ...
0
by: Allan Tennent | last post by:
My problem: to allow the user of the website to select any part or parts of day over a whole 7 day week. A day will be split into 24 hour parts or 48 ˝ hour parts. My approach was inspired by...
1
by: anithabg | last post by:
I am doing the implementation of ATC using CPU Scheduling Algorithms. I will give a group of flights information(landing time,arrival time) at the beginning.Then it will schedule the landing based...
3
by: ken.ditto | last post by:
I have a database that stores data collected from a variety of instruments (pressure, temperature, flow rate, etc.) everytime there is a 1% change in the value. The Project Manager wants to be...
1
by: Yammi | last post by:
Ok, I know that there is a very smart programmer out there that can resovle my issue. I am trying to calculate time worked by 15 minute intervals. Example: ================= Emp 1 started...
4
by: luxsphinx | last post by:
OS: Ubuntu Linux PHP: v5.3.2 MySQL: v5.1.41 Hello all, I'm new to Bytes, but I'm hoping that someone here will be able to help me as I learn PHP and MySQL. With any luck, I'll understand it...
1
by: DavidThickins | last post by:
I have an MS Access 2010 database which when opened, displays one of three Care Home Duty Rosters as part of its top menu. It can be an Early, Late or Night Roster depending on which 8-hour segment...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.