Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Between Times Access VBA

Posted on 2014-03-13
5
Medium Priority
?
597 Views
Last Modified: 2014-03-13
I have a Time field that records the time of day a record was added (Not Date).

I want an event to occur if when this time is achieved (there are other filters which control the event).

In simple terms I want the event to occur if between Now() -1 30 minutes and Now() + 30 minutes, but not referring to a Date.
0
Comment
Question by:SparkyP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 85
ID: 39926004
So you need something that counts up to your interval?

If you're doing this on a Form, you could use the form's Timer event. To do that:

1. Add a Date variable to the General Declarations section of the form to hold the value of "Now"

2. When you want to start the count up:

dtYourVariable = Now

And set the Timer's interval to something like 2000 (which means it'll fire every 2 seconds). This essentiall starts the timer.

3. In the form's Timer event:

'/ "n" is the DateAdd value for Minutes
If DateAdd("n", 30, dtYourVariable) > Now Then
  '/ do what you want here
  Me.TimerInterval = 0 '<< stops the timer
End If
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39926122
you can use the Time() function instead of Now() since you don't want the date part.
0
 

Author Comment

by:SparkyP
ID: 39926168
Scott

I'm sure your solution would work, but I was hoping for a simpler solution, like between Time() - 30 and Time() +30, with the 30's being in seconds.

From your reply this isn't possible?
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 39926297
I don't think I understood your issue at first ...

So you have a field in a table, and you've recorded the Time a record was inserted/updated (or whatever).

If so, then you could do something like this in the Form's Timer event:

If Me.YourTimeField > Time(Now) and Me.YourTimeField < DateAdd("n", 30, Time(Now)) Then
  '/ do something here
End If
0
 

Author Closing Comment

by:SparkyP
ID: 39926309
Thanks Scott
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question