Solved

Detecting when the week number changes

Posted on 2003-10-28
2
156 Views
Last Modified: 2010-05-03
Hi Experts,

I know how to get the week number in visual basic using:

datepart("ww", date)

But does anyone know how to trigger an event when the week number changes?

Preferably without the use of a timer control


Thanks,
Robbrownuk
0
Comment
Question by:robbrownuk
2 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9633016
You do need to create a 'timer' to listening your request, then your application then can rect based on the response returned from the listener.

Alternatively by Not using a timer control, you can do a timer via SetTimer API, example like below:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q180/7/36.asp&NoWebContent=1

http://www.mvps.org/vbnet/code/forms/flashwindowsettimer.htm

Hope this helps
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 30 total points
ID: 9633874
Are you just waiting for the week to change?  A simple way would be to sleep until it happens.  Note you don't want to sleep too long at a shot or your app won't respond to shutdown requests, etc.

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
    Dim currentweek As Integer
    currentweek = DatePart("ww", Date)
    While currentweek = DatePart("ww", Date)
        Sleep (5000) 'sleep for 5 seconds
    Wend
    'now the week has changed
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 47
Sending a email via excel using vba 6 72
message box in access 4 41
Getting warning: You are about to delete 1 row(s) 9 43
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now