Error 6 Overflow

  • Thread starter Frankie via AccessMonster.com
  • Start date
F

Frankie via AccessMonster.com

Can someone please help me with the following code that now produces an error
6 overflow message :

Function JoursOuvres(deb, fin)
Dim db As Database
Dim r As Recordset
Dim jours As Integer
Dim temp

Set db = CurrentDb()
Set r = db.OpenRecordset("tblJoursFeries")

temp = deb
jours = 0
Do While temp <= fin
If (DatePart("w", temp) <> 1) And (DatePart("w", temp) <> 7) Then
jours = jours + 1
End If
temp = DateAdd("d", 1, temp)
Loop
r.MoveFirst
Do While Not r.EOF
If r("JoursFeries") >= deb And r("JoursFeries") <= fin And _
DatePart("w", r("JoursFeries")) <> 7 And _
DatePart("w", r("JoursFeries")) <> 1 Then
jours = jours - 1
End If
r.MoveNext
Loop
r.Close
JoursOuvres = jours
End Function

When I run the debuging tool it focuses on "Jours = Jours + 1 ".
I just don't get it !

Thanks in advance for your response
Frankie
 
R

RoyVidar

Frankie via AccessMonster.com wrote in message said:
Can someone please help me with the following code that now produces an error
6 overflow message :

Function JoursOuvres(deb, fin)
Dim db As Database
Dim r As Recordset
Dim jours As Integer
Dim temp

Set db = CurrentDb()
Set r = db.OpenRecordset("tblJoursFeries")

temp = deb
jours = 0
Do While temp <= fin
If (DatePart("w", temp) <> 1) And (DatePart("w", temp) <> 7) Then
jours = jours + 1
End If
temp = DateAdd("d", 1, temp)
Loop
r.MoveFirst
Do While Not r.EOF
If r("JoursFeries") >= deb And r("JoursFeries") <= fin And _
DatePart("w", r("JoursFeries")) <> 7 And _
DatePart("w", r("JoursFeries")) <> 1 Then
jours = jours - 1
End If
r.MoveNext
Loop
r.Close
JoursOuvres = jours
End Function

When I run the debuging tool it focuses on "Jours = Jours + 1 ".
I just don't get it !

Thanks in advance for your response
Frankie

Without studying here, one suggestion is that integer is too small
for the operations you're doing. Try declaring "jours" as long.
 
F

Frankie via AccessMonster.com

Thank you for your response Roy.
I did try that after reading some posts but then I have an error 5 message.
Any idea ??
Frankie via AccessMonster.com wrote in message said:
Can someone please help me with the following code that now produces an error
6 overflow message :
[quoted text clipped - 34 lines]
Thanks in advance for your response
Frankie

Without studying here, one suggestion is that integer is too small
for the operations you're doing. Try declaring "jours" as long.
 
R

RoyVidar

Frankie via AccessMonster.com wrote in message said:
Thank you for your response Roy.
I did try that after reading some posts but then I have an error 5 message.
Any idea ??
Frankie via AccessMonster.com wrote in message said:
Can someone please help me with the following code that now produces an
error 6 overflow message : [quoted text clipped - 34 lines]
Thanks in advance for your response
Frankie

Without studying here, one suggestion is that integer is too small
for the operations you're doing. Try declaring "jours" as long.

Without knowing which line, I haven't the foggiest. I think this error
can have lot of probable causes, from syntax errors to reference
issues... (RT 5: Invalid procedure call or argument?)

Try debugging - set a breakpoint on the first executable line (F9),
then
try to run it. Use step into (F8) to step through the function line by
line. Examine the values of the variables by hovering the mouse over
them (or select them and do Shift+F9 for quick watch...) and see if you
can find out where it goes wrong.

Also, I don't understand what this function is supposed to do. Perhaps
some info on that can help someone helping you?

Since you do not declare your parameters for this function, one
question
would be whether you call it with valid arguements. Another, perhaps
related to the DatePart function, see for instance
http://support.microsoft.com/?kbid=288194
 
F

Frankie via AccessMonster.com

Sorry for coming back so late.
This function returns working days only out of a start date and end date.
It worked really fine until I added data to the system yesterday. Now it
shows error 6 messages.
As I said before if I change Integer for long I get an error 5 message with
a yellow highlighted part of the function which is : temp = DateAdd("d", 1,
temp).
I am really stcuk and really need to find a solution ASAP.
For the records I am not a professionel developper. I created this DB for my
business and it worked very well so far. Seemingly I must have done something
wrong.
Any more thoughts??
Frankie via AccessMonster.com wrote in message said:
Thank you for your response Roy.
I did try that after reading some posts but then I have an error 5 message.
[quoted text clipped - 8 lines]
Without knowing which line, I haven't the foggiest. I think this error
can have lot of probable causes, from syntax errors to reference
issues... (RT 5: Invalid procedure call or argument?)

Try debugging - set a breakpoint on the first executable line (F9),
then
try to run it. Use step into (F8) to step through the function line by
line. Examine the values of the variables by hovering the mouse over
them (or select them and do Shift+F9 for quick watch...) and see if you
can find out where it goes wrong.

Also, I don't understand what this function is supposed to do. Perhaps
some info on that can help someone helping you?

Since you do not declare your parameters for this function, one
question
would be whether you call it with valid arguements. Another, perhaps
related to the DatePart function, see for instance
http://support.microsoft.com/?kbid=288194
 
R

RoyVidar

Frankie via AccessMonster.com wrote in message said:
Sorry for coming back so late.
This function returns working days only out of a start date and end date.
It worked really fine until I added data to the system yesterday. Now it
shows error 6 messages.
As I said before if I change Integer for long I get an error 5 message with
a yellow highlighted part of the function which is : temp = DateAdd("d", 1,
temp).
I am really stcuk and really need to find a solution ASAP.
For the records I am not a professionel developper. I created this DB for my
business and it worked very well so far. Seemingly I must have done something
wrong.
Any more thoughts??

Look, I don't really now. I do suspect several things, which I've
alredy
spoken about.

Ensure you send valid dates to this function

Function JoursOuvres(ByVal deb as Date, ByVal fin as Date) as Long

and tht the dates you work with, are understood/accepted as dates

Dim temp as date

Or test/validate that you have valid dates within the function. I
wouldn 't be surprised if it barfed cause the date was higher than
12/31/9999 due to incorrect dates passed to the function.

For what I know, it could be an issue about reserwed words. I
understand
there are localizied French versions around where "jours", "fin", "deb"
could be reserved words. Stuff like that can be avoided by using one of
the naming conventions around.

I would also ensure there are records in the table prior to addressing
it (though unrelated to this)

if not r.bof and not r.eof then
r.MoveFirst
Do While Not r.EOF
...

For later usage, but unrelated to this, you might also look at explicit
declarations

Dim db As DAO.Database
Dim r As DAO.Recordset
 
F

Frankie via AccessMonster.com

Thank you for your answer.
I will try your recomendations and will let you know.

Frankie via AccessMonster.com wrote in message said:
Sorry for coming back so late.
This function returns working days only out of a start date and end date.
[quoted text clipped - 8 lines]
wrong.
Any more thoughts??

Look, I don't really now. I do suspect several things, which I've
alredy
spoken about.

Ensure you send valid dates to this function

Function JoursOuvres(ByVal deb as Date, ByVal fin as Date) as Long

and tht the dates you work with, are understood/accepted as dates

Dim temp as date

Or test/validate that you have valid dates within the function. I
wouldn 't be surprised if it barfed cause the date was higher than
12/31/9999 due to incorrect dates passed to the function.

For what I know, it could be an issue about reserwed words. I
understand
there are localizied French versions around where "jours", "fin", "deb"
could be reserved words. Stuff like that can be avoided by using one of
the naming conventions around.

I would also ensure there are records in the table prior to addressing
it (though unrelated to this)

if not r.bof and not r.eof then
r.MoveFirst
Do While Not r.EOF
...

For later usage, but unrelated to this, you might also look at explicit
declarations

Dim db As DAO.Database
Dim r As DAO.Recordset
 
F

Frankie via AccessMonster.com

Thank you very much Roy, I did what you say (Dim temp as date) and it works
fine now.
Once again, Access Monster gave me the answer.
Great site, keep on
Frankie
Frankie via AccessMonster.com wrote in message said:
Sorry for coming back so late.
This function returns working days only out of a start date and end date.
[quoted text clipped - 8 lines]
wrong.
Any more thoughts??

Look, I don't really now. I do suspect several things, which I've
alredy
spoken about.

Ensure you send valid dates to this function

Function JoursOuvres(ByVal deb as Date, ByVal fin as Date) as Long

and tht the dates you work with, are understood/accepted as dates

Dim temp as date

Or test/validate that you have valid dates within the function. I
wouldn 't be surprised if it barfed cause the date was higher than
12/31/9999 due to incorrect dates passed to the function.

For what I know, it could be an issue about reserwed words. I
understand
there are localizied French versions around where "jours", "fin", "deb"
could be reserved words. Stuff like that can be avoided by using one of
the naming conventions around.

I would also ensure there are records in the table prior to addressing
it (though unrelated to this)

if not r.bof and not r.eof then
r.MoveFirst
Do While Not r.EOF
...

For later usage, but unrelated to this, you might also look at explicit
declarations

Dim db As DAO.Database
Dim r As DAO.Recordset
 
D

Douglas J. Steele

Just to clear up, Access Monster didn't give you the answer. The answer was
posted to newsgroup microsoft.public.access.queries. AccessMonster appears
to be simply some sort of web interface to the Microsoft newsgroups.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Frankie via AccessMonster.com said:
Thank you very much Roy, I did what you say (Dim temp as date) and it
works
fine now.
Once again, Access Monster gave me the answer.
Great site, keep on
Frankie
Frankie via AccessMonster.com wrote in message said:
Sorry for coming back so late.
This function returns working days only out of a start date and end
date.
[quoted text clipped - 8 lines]
wrong.
Any more thoughts??

Look, I don't really now. I do suspect several things, which I've
alredy
spoken about.

Ensure you send valid dates to this function

Function JoursOuvres(ByVal deb as Date, ByVal fin as Date) as Long

and tht the dates you work with, are understood/accepted as dates

Dim temp as date

Or test/validate that you have valid dates within the function. I
wouldn 't be surprised if it barfed cause the date was higher than
12/31/9999 due to incorrect dates passed to the function.

For what I know, it could be an issue about reserwed words. I
understand
there are localizied French versions around where "jours", "fin", "deb"
could be reserved words. Stuff like that can be avoided by using one of
the naming conventions around.

I would also ensure there are records in the table prior to addressing
it (though unrelated to this)

if not r.bof and not r.eof then
r.MoveFirst
Do While Not r.EOF
...

For later usage, but unrelated to this, you might also look at explicit
declarations

Dim db As DAO.Database
Dim r As DAO.Recordset
 

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