Re: Bizarre error involving date function
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Wed, 13 Sep 2006 13:14:28 -0500
Bruce, That's definitely a simplification of "an algorithm
which returns the correct # of days in a given month"
However, it would be better to set the text box's
DefaultValue property instead of the Value. This way, the
new record would not be dirtied in case the user decides not
to continue.
If Me.NewRecord Then
Me.txtMonthStart.DefaultValue = _
Format(DateSerial(Year(Date()), Month(Date()), 1), _
"\#m\/d\/yyyy\#")
. . .
Richard, it doesn't matter what library a function is in.
If any needed Reference is missing, all bets are off on any
function in every library. You need to make sure that every
referenced library actually is installed and in the same
place on both machines. Because this can be a serious
hassle, you should not reference a library unless there is
no other way to do the job.
--
Marsh
MVP [MS Access]
BruceM wrote:
I don't know why you're having the difficulties you are, so I will leave it.
to others to provide guidance on that point, but you may be making this more
difficult than it needs to be. DateSerial will interpret the 0 day of a
month as the last day of the previous month. You could use something like
this:
If Me.NewRecord Then
Me.txtMonthStart =
Format(DateSerial(Year(Date()),Month(Date()),1,"m/d/yyyy")
Me.txtMonthEnd =
Format(Dateserial(Year(Date()),Month(Date())+1,0),"m/d/yyyy")
End If
This assumes that the text boxes txtMonthStart and txtMonthEnd are bound,
and that you want the value to be entered only if it is a new record. I
expect you could use these expressions as the default value of those text
boxes to accomplish the same thing. If your situation differs from these
assumptions the expression can be altered as needed.
"Richard Harison" <noway@xxxxxxxxxxx> wrote
Hello! I need help!
I have written an extensive db and a popup form involves the date
function. I wrote a VB routine that automatically puts the 1st of the
present month into one text box and the last day of the present month in a
second. Here is the key line:
MonthEnd = DatePart("m", BeginningDate) & "/" & LastDay & "/" &
DatePart("yyyy", Date)
(LastDay is derived from an algorithm which returns the correct # of days
in a given month)
I am using Access 2002. When I imported the db to another 2002 computer
the popup form displayed a #NAME error. I found that the problem lay in a
VB library which wasn't active (DAO 3.6 as I recall). I added that
library to references and it worked fine -- on 2002 machines!
Problem now is it will not work in Access 2003. Yet when I look in
references it shows the DAO 3.6 checked.I tried converting the db to 2003,
but the menu says "2002-2003" which says to me that no conversion is
necessary.
Is it possible that the Date function is in another library in 2003?
- Follow-Ups:
- Re: Bizarre error involving date function
- From: Richard Harison
- Re: Bizarre error involving date function
- From: BruceM
- Re: Bizarre error involving date function
- References:
- Bizarre error involving date function
- From: Richard Harison
- Re: Bizarre error involving date function
- From: BruceM
- Bizarre error involving date function
- Prev by Date: Re: Hiding a combo box with Option Selection
- Next by Date: Re: Dialog Form for Date Variables Won't Close
- Previous by thread: Re: Bizarre error involving date function
- Next by thread: Re: Bizarre error involving date function
- Index(es):
Relevant Pages
|