473,406 Members | 2,439 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,406 software developers and data experts.

Help with finding a date ??

I have two date fields.
PaymentDate - is set to default to today : =Date()
MeetingDate - is going to find the next meeting date after the PaymentDate

So using April as an example:

If today's date is 4/22/2008 , I want the MeetingDate field to look up the
NEXT meeting this month... this would show as 4/23/2008.
If today's date is 4/29/2008, then I need the query to find the NEXT meeting
date which would be 5/28/2008.
So the logic is :
If (Today is less than the fourth wednesday of current month, Then show the
fourth of this month, Else show the next fourthof the month)

How can I have this meeting date pre-fill like this?

Jun 27 '08 #1
1 1197
Do you always want the date to be the "next" 4th Wednesday of the month, or
perhaps the last Wednesday? Some months have 5?

I shall assume 4th wed of the month.

The way to set this up is to use the forms before-insert event.
(this event ONLY fires if the user starts typing into the record - but, if
the user looks at the blank record, and closes the form, then you don't get
a blank record added..so, it a good spot....

Assuming our control paymentdate is set to "date", then we can go:

dim dtTempDate as date
if isnull(me.PaymentDate) = false then

dtTempdate = Get4Wed(me.PaymentDate)

if me.Paymentdate dtTempDate then
' we after the last month, so
' jump ahead
dtTempdate = DateSerial(Year(dtDate), Month(dtDate) + 1, 1)
dtTempDate = Get4Wed(dtTempDate)
end if

me.meetingDate = dtTempDate

end if

I also wrote a get 4th wed function for a give date value..it follows my sig

Some of the better developers here could likely write out the whole thing as
a SINGLE expression, but my brain just don't work that way!!!
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com

paste the follwing code into a standard code module..make sure it compiles
also...
Public Function Get4Wed(dtDate As Date) As Date

Dim intFirstW As Integer
Dim dtFirst As Date
Dim dtFirstW As Date

' get 1st day of this month
dtFirst = DateSerial(Year(dtDate), Month(dtDate), 1)

' get 1st wed of this month
intFirstW = 4 - Weekday(dtFirst)
If intFirstW < 0 Then
intFirstW = intFirstW + 7
End If

dtFirstW = dtFirst + intFirstW
dtFirstW = dtFirstW + 21

Get4Wed = dtFirstW

End Function

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MAB | last post by:
I have a table Create Table Payments { paymentid int, customerid int, amount int, date datetime } What I want is the sum of the amounts of the last payments of all customers.
0
by: jaggee | last post by:
Hello, This is regarding log analysis of a web system, I am finding my backend SQL programming has taken so much of time to process the application due to following quires for a log table having...
18
by: Jeremy Weiss | last post by:
I'm trying to build a database that will handle the monthly billing needs of a small company. I'm charting everything out and here's what I see: table for customers sub table to track payments...
2
by: Douglas | last post by:
I have a Vehicle MOT field in my table which i have as a Date field I dont really want to hold the year, just 'dd mmm' as MOTs are the same date every year. I have the field on my form as a...
38
by: Red Dragon | last post by:
I am self study C student. I got stuck in the program below on quadratic equation and will be most grateful if someone could help me to unravel the mystery. Why does the computer refuse to execute...
0
by: Brian Henry | last post by:
Ok I've never implemented a snap location before so I dont really know what im doing wrong here... anyways, I am making a custom slider control that takes dates as its values instead of integers......
2
by: Extremest | last post by:
Here is the code I have so far. It connects to a db and grabs headers. It then sorts them into groups and then puts all the complete ones into another table. Problem I am having is that for some...
4
by: richierich | last post by:
First what I need help with is in a report that I have that I have hauled multiple truck loads with a particular truck on a particular day and I want on the report to show me on the footer of the...
1
by: shauna | last post by:
hi, i am an As level student studying Applied ICT, im having problems with normalisation. our problem is to computerise a made up business.mine for example is a beauty salon. below are my...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.