Auto Notification

D

David McLean

Hi Everyone,

I'm trying to figure out a way to have a form pop up in my database
automatically on the first day of each month that would show a query. would
anybody be able to point me in the right direction?

Take Care,
 
D

Dorian

That's easy, just set an initial form in your startup options. Put some code
in the OPEN event of this form to get the current date and check if it's the
first of the month and if it is, open your special form. You can have the
initial form be invisible (property visible = false) if you don't want to see
the initial screen.
Look in Access Help for Date functions.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
D

David McLean

Oh thank you very much!

Dorian said:
That's easy, just set an initial form in your startup options. Put some
code
in the OPEN event of this form to get the current date and check if it's
the
first of the month and if it is, open your special form. You can have the
initial form be invisible (property visible = false) if you don't want to
see
the initial screen.
Look in Access Help for Date functions.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and
they
eat for a lifetime".
 
D

Dale_Fye via AccessMonster.com

Did I sense some sarcasm?

David,

It really depends on what you want to do with the query, but Dorian's concept
was generally what I would recommend, even if her response was a bit abbrupt.

Generally, I have a "Splash" screen, which identifies my application and
provides users various options, depending on their permissions (some call
this a switchboard). The point is that in this forms Load event, I would
have some code that determines whether today is the first day of the month
(my guess is that you probably want the first work day of the month, so that
is where I will start).

Start out with a function that will return the first workday of a given month.
Something like:

Public Function fnFirstWorkday(Optional SomeDate As Variant = Null) As Date

Dim dtLoop As Date

If IsNull(SomeDate) Then SomeDate = Date
For dtLoop = DateSerial(Year(SomeDate), Month(SomeDate), 1) To _
DateSerial(Year(SomeDate), Month(SomeDate), 7)
If Weekday(dtLoop, vbSaturday) > 2 Then
fnFirstWorkday = dtLoop
Exit For
End If
Next

End Function

Then, in the forms Load event, add some code that looks similar to:

Private Sub Form_Load

if fnFirstWorkday = Date() then
docmd.OpenQuery "query name"
end if

end sub

Personally, I would not open a query like this, I would create a continuous
form that uses the query as its Record Source.

HTH
Dale

David said:
Oh thank you very much!
That's easy, just set an initial form in your startup options. Put some
code
[quoted text clipped - 18 lines]
 
D

David McLean

haha, sorry, reading that again i can see it coming off as sarcastic. trust
me though, it wasnt, i've been struggling on this one for far too long.
apologies for the miscommunication. Thanks very much.

Dale_Fye via AccessMonster.com said:
Did I sense some sarcasm?

David,

It really depends on what you want to do with the query, but Dorian's
concept
was generally what I would recommend, even if her response was a bit
abbrupt.

Generally, I have a "Splash" screen, which identifies my application and
provides users various options, depending on their permissions (some call
this a switchboard). The point is that in this forms Load event, I would
have some code that determines whether today is the first day of the month
(my guess is that you probably want the first work day of the month, so
that
is where I will start).

Start out with a function that will return the first workday of a given
month.
Something like:

Public Function fnFirstWorkday(Optional SomeDate As Variant = Null) As
Date

Dim dtLoop As Date

If IsNull(SomeDate) Then SomeDate = Date
For dtLoop = DateSerial(Year(SomeDate), Month(SomeDate), 1) To _
DateSerial(Year(SomeDate), Month(SomeDate), 7)
If Weekday(dtLoop, vbSaturday) > 2 Then
fnFirstWorkday = dtLoop
Exit For
End If
Next

End Function

Then, in the forms Load event, add some code that looks similar to:

Private Sub Form_Load

if fnFirstWorkday = Date() then
docmd.OpenQuery "query name"
end if

end sub

Personally, I would not open a query like this, I would create a
continuous
form that uses the query as its Record Source.

HTH
Dale

David said:
Oh thank you very much!
That's easy, just set an initial form in your startup options. Put some
code
[quoted text clipped - 18 lines]
Take Care,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top