سؤال

I am using MS Access 365 (2013) and are having run-time errors on even the most simple calls to object methods on the ActiveGanttVCCtl object.

Using the supplied 'Getting started' guide on the ActiveGantt website (http://www.sourcecodestore.com/Article.aspx?ID=15#Create3), I am receiving a run-time error (424 Object Required) on any one of the four lines of code following the for loop. The code is supplied here again for convenience.

Option Compare Database
Option Explicit

Public Function ActiveGanttVCCtl1() As ActiveGanttVCCtl
    Set ActiveGanttVCCtl1 = ActiveGanttVCCtl1A.Object
End Function

Private Sub Form_Load()
    Dim i As Integer
    ActiveGanttVCCtl1.Columns.Add "Column 1", "", 125, ""
    ActiveGanttVCCtl1.Columns.Add "Column 2", "", 100, ""
    For i = 1 To 10
        ActiveGanttVCCtl1.Rows.Add "K" & i, "Row " & i, True, True, ""
    Next
    ActiveGanttVCCtl1.CurrentViewObject.TimeLine.Position DateSerial(2011, 11, 2)
    ActiveGanttVCCtl1.Tasks.Add "Task 1", "K1", DateSerial(2011, 11, 2) + TimeSerial(0, 0, 0), DateSerial(2011, 11, 2) + TimeSerial(3, 0, 0), "", "", ""
    ActiveGanttVCCtl1.Tasks.Add "Task 2", "K2", DateSerial(2011, 11, 2) + TimeSerial(1, 0, 0), DateSerial(2011, 11, 2) + TimeSerial(4, 0, 0), "", "", ""
    ActiveGanttVCCtl1.Tasks.Add "Task 3", "K3", DateSerial(2011, 11, 2) + TimeSerial(2, 0, 0), DateSerial(2011, 11, 2) + TimeSerial(5, 0, 0), "", "", ""
End Sub

Please note that the error does not occur until the line

ActiveGanttVCCtl1.CurrentViewObject.TimeLine.Position DateSerial(2011, 11, 2)

The reference to the ActiveGanttVC Scheduler Component library has been included (it would given a compile error otherwise) and an ActiveGantt ActiveX control exists on the form named ActiveGanttVCCtl1A. I have also tried declaring the ActiveGanttVCCtl object within the Form_Load() function itself rather than in a separate function but get the same result.

I have also determined that at the point of the run-time error, I am able to access the ActiveGanttVCCtl1.CurrentViewObject.TimeLine object as I can run the GetXML method on it without any problems, just not the Position method.

I have tried also commenting this particular line out, however I receive the same run-time error on the next line of code (the call to tasks.add). Creating further calls to the columns.add or rows.add methods, however, still appears to work fine at this position in the code.

Is it possible that there are issues in MS Access 2013 that do not appear in MS Access 2010 for this control?

هل كانت مفيدة؟

المحلول

This is happening because the version of ActiveGanttVC you are using uses AGVC.DateTime instead of the regular VB/VBA Date. AGVC.DateTime was introduced in ActiveGanttVC to allow millisecond, microsecond and nanosecond accuracy (which turned out not to be a good idea at all), the next version of ActiveGanttVC (3.2.0) will use the regular VB6/VBA Date (COleDateTime for C++ users). In the meantime you will have to use this helper function when specifying a date in ActiveGanttVC:

Public Function FromDate(ByVal dtDate As Date) As AGVC.DateTime
      Dim dtReturn As New AGVC.DateTime
      Dim lYear As Long
      Dim lMonth As Long
      Dim lDay As Long
      Dim lHour As Long
      Dim lMinute As Long
      Dim lSecond As Long
      lYear = Year(dtDate)
      lMonth = Month(dtDate)
      lDay = Day(dtDate)
      lHour = Hour(dtDate)
      lMinute = Minute(dtDate)
      lSecond = Second(dtDate)
      dtReturn.Initialize lYear, lMonth, lDay, lHour, lMinute, lSecond, 0, 0, 0
      Set FromDate = dtReturn
End Function


ActiveGanttVCCtl1.CurrentViewObject.TimeLine.Position FromDate(DateSerial(2011, 11, 2))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top