Overflow (#6) Error When Assigning a Date Data Type

jaunito

New Member
Joined
Jun 10, 2004
Messages
10
I have a class that imports date values from a worksheet and then stores them in a class along with a lot of other information. The problem is when I try to move from the private variable holding the date information to the public property, it is giving me an overflow error. I tested this two days ago (the exact same code) and did not get any errors in execution, so I'm quite confused as to what might be causing it.
VBA Code:
Property Let FlightDate(pd As Date)
pdFlightDate = pd
End Property
Property Get FlightDate() As Date
FlightDate = pdFlightDate
End Property
When I set (let) the date I don't get a problem, but when I try to return the date I'm getting a problem. I'm working in Office 365 on a Mac trying to make it work on the Mac Platform, but I don't think this is a Mac Related issue.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
What module code are you using to get the FlightDate?

Have you perhaps accidentally declared your flight date variable as Integer?
 
Upvote 0
What module code are you using to get the FlightDate?

Have you perhaps accidentally declared your flight date variable as Integer?
I'm using a testing module called test, that really doesn't do anything other than create the object and call a function that loads this object into memory. This code works beautifully, but when I try to pull the data out again it causes the overflow error. The value that is causing it to crash is 6/8/11. This should be a fairly normal date and is well within the parameters of dates that can be accessed. Unless of course 6/8/11 is in the actual year 11 and not 2011. I'll get back to you on that.
 
Upvote 0
I'm using a testing module called test, that really doesn't do anything other than create the object and call a function that loads this object into memory. This code works beautifully, but when I try to pull the data out again it causes the overflow error. The value that is causing it to crash is 6/8/11. This should be a fairly normal date and is well within the parameters of dates that can be accessed. Unless of course 6/8/11 is in the actual year 11 and not 2011. I'll get back to you on that.
That year 11 would have been too simple, it is actually 2011...
 
Upvote 0
I'm using a testing module called test, that really doesn't do anything other than create the object and call a function that loads this object into memory ....

Ok, but can you post this code? Otherwise we can only guess what might be happening.

Also, how are you declaring pdFlightDate in your class module?
 
Upvote 0
So I edited the calling function and it does not seem to cause an overflow any longer. This is not satisfying at all because, I have not modified the offending "FlightDate" property that was causing the error in the first place, but the error just disappeared. So maybe this is a Mac bug that I discovered, or maybe it just decided that it wanted to work for me today. Hopefully it will work tomorrow.
 
Upvote 0
Ok, but can you post this code? Otherwise we can only guess what might be happening.

Also, how are you declaring pdFlightDate in your class module?
Here is the code:

VBA Code:
Public Sub TestPlanes()

    Dim myFlights As New CFlights
    Dim LastRow As Long
    
    LastRow = wsxNavyList.Range("B" & wsxNavyList.Rows.Count).End(xlUp).Row
    Debug.Print myFlights.GetNavyFlights(wsxNavyList.Range("B11:AI" & LastRow))
    LastRow = 0
    For Each Flight In myFlights
        LastRow = LastRow + 1
        Debug.Print Flight
    Next Flight
End Sub
 
Upvote 0
Here is the code:

VBA Code:
Public Sub TestPlanes()

    Dim myFlights As New CFlights
    Dim LastRow As Long
   
    LastRow = wsxNavyList.Range("B" & wsxNavyList.Rows.Count).End(xlUp).Row
    Debug.Print myFlights.GetNavyFlights(wsxNavyList.Range("B11:AI" & LastRow))
    LastRow = 0
    For Each Flight In myFlights
        LastRow = LastRow + 1
        Debug.Print Flight
    Next Flight
End Sub

GetNavyFlight calls a CFlights method to populate the CFlights collection (colFligts) full of CFlight objects. These objects are loaded through a GetNavyFlight that receives a row of data and populates the object with the data. All of this code is now working somehow without me changing anything discernible to the CFlights.FlightDate property which was causing an overflow error in its Get routine posted above. Frankly I'm pretty baffled by this behavior of the Date data type, I've been doing vba code for 20 years and I have not run into this issue before.
 
Upvote 0
OK, a little more complicated than the original post. Can you please:

- Post all the relevant code.
- Provide a screenshot of wsxNavyList (so we can see the range and values)
- Indicate which line of code is producing the overflow error
 
Upvote 0
Here is the code:

VBA Code:
Public Sub TestPlanes()

    Dim myFlights As New CFlights
    Dim LastRow As Long
   
    LastRow = wsxNavyList.Range("B" & wsxNavyList.Rows.Count).End(xlUp).Row
    Debug.Print myFlights.GetNavyFlights(wsxNavyList.Range("B11:AI" & LastRow))
    LastRow = 0
    For Each Flight In myFlights
        LastRow = LastRow + 1
        Debug.Print Flight
    Next Flight
End Sub
How about sharing the code for CFlights? And, where do you initialize wsxNavyList?
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,344
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top