Using MS Access to populate fields in Project - UPDATE 
Author Message
 Using MS Access to populate fields in Project - UPDATE

I created a command button on one of my MS Access application pages using a
module containing the code below.  I can now open MS Project with no
problem.  But as soon as I add, or remove the comments " ' " from, the line
of code, "objProject.SetTaskField "Predecessors", dynTasks!Predecessors,
intCurrTask",
ALL THE OTHER LINES WORK
I get the following error message when I click on the command button:

     Run-time error '1101':
     The argument value is not valid.
     Check that the value is correct and that it is the correct type for the
argument.

When I select the "Debug" option, my code appears with the
"objProject.SetTaskField "Predecessors", dynTasks!Predecessors, intCurrTask"
line highlighted.

Let me add, I have made certain that I correctly used the field names in
both MS Project and my MS Access application.  The same problem occurs on
two separate MS Access 98 and MS Access 2000 machines.

Here is the full description of the code use in the module:

Option Compare Database

Function AccessToProjectAutomation()

Dim dblocal As Database
Dim dynTasks As Recordset
Dim intCurrTask As Integer

'On Error GoTo Error_OLEAccessToProject

Set dblocal = CurrentDb()

Set dynTasks = dblocal.OpenRecordset("Tasks", dbOpenDynaset)

'--Create an instance of Project
Set objProject = CreateObject(Class:="MSProject.Application")

With objProject
.DisplayAlerts = False
.FileNew
End With

'--Initialize the counter for the Unique Task ID
intCurrTask = 0

Do Until dynTasks.EOF

'--Increment the counter for the Task ID
intCurrTask = intCurrTask + 1

'--Use the SetTaskField method to
'--Write data from Access record to Project

   objProject.SetTaskField "Name", dynTasks!Tasks, intCurrTask
  objProject.SetTaskField "Start", dynTasks!start, intCurrTask
 objProject.SetTaskField "Duration", dynTasks!Duration, intCurrTask
 objProject.SetTaskField "Predecessors", dynTasks!Predecessors, intCurrTask
 objProject.SetTaskField "Resource Names", dynTasks!Resources, intCurrTask

dynTasks.MoveNext

Loop

'--Make project visible
With objProject
.Visible = True
.AppMaximize
End With

Exit Function

Error_OLEAccessToProject:

Beep
MsgBox "The following OLE Error has occurred:" & vbCrLf & Err.description,
vbCritical, "Ole Error!"

Exit Function

End Function



Tue, 28 Aug 2001 03:00:00 GMT  
 Using MS Access to populate fields in Project - UPDATE
So ...

What's the data type and value of dynTasks!Predecessors?

Quote:

>I created a command button on one of my MS Access application pages using a
>module containing the code below.  I can now open MS Project with no
>problem.  But as soon as I add, or remove the comments " ' " from, the line
>of code, "objProject.SetTaskField "Predecessors", dynTasks!Predecessors,
>intCurrTask",
>ALL THE OTHER LINES WORK
>I get the following error message when I click on the command button:

>     Run-time error '1101':
>     The argument value is not valid.
>     Check that the value is correct and that it is the correct type for
the
>argument.

>When I select the "Debug" option, my code appears with the
>"objProject.SetTaskField "Predecessors", dynTasks!Predecessors,
intCurrTask"
>line highlighted.

>Let me add, I have made certain that I correctly used the field names in
>both MS Project and my MS Access application.  The same problem occurs on
>two separate MS Access 98 and MS Access 2000 machines.

>Here is the full description of the code use in the module:

>Option Compare Database

>Function AccessToProjectAutomation()

>Dim dblocal As Database
>Dim dynTasks As Recordset
>Dim intCurrTask As Integer

>'On Error GoTo Error_OLEAccessToProject

>Set dblocal = CurrentDb()

>Set dynTasks = dblocal.OpenRecordset("Tasks", dbOpenDynaset)

>'--Create an instance of Project
>Set objProject = CreateObject(Class:="MSProject.Application")

>With objProject
>.DisplayAlerts = False
>.FileNew
>End With

>'--Initialize the counter for the Unique Task ID
>intCurrTask = 0

>Do Until dynTasks.EOF

>'--Increment the counter for the Task ID
>intCurrTask = intCurrTask + 1

>'--Use the SetTaskField method to
>'--Write data from Access record to Project

>   objProject.SetTaskField "Name", dynTasks!Tasks, intCurrTask
>  objProject.SetTaskField "Start", dynTasks!start, intCurrTask
> objProject.SetTaskField "Duration", dynTasks!Duration, intCurrTask
> objProject.SetTaskField "Predecessors", dynTasks!Predecessors, intCurrTask
> objProject.SetTaskField "Resource Names", dynTasks!Resources, intCurrTask

>dynTasks.MoveNext

>Loop

>'--Make project visible
>With objProject
>.Visible = True
>.AppMaximize
>End With

>Exit Function

>Error_OLEAccessToProject:

>Beep
>MsgBox "The following OLE Error has occurred:" & vbCrLf & Err.description,
>vbCritical, "Ole Error!"

>Exit Function

>End Function



Tue, 28 Aug 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using MS Access to populate specific fields in MS Project

2. Updating Memo Fields in MS Access using ADO Parameter / Stored Procedures

3. Updating Memo Fields in MS Access using ADO Parameter / Stored Procedures

4. ASP.NET update task in MS Project Server and MS Project

5. Using MS Access 97 to Create and Manage MS Project 98

6. Populating memo field using update query from VB5

7. Populating MS Access field description

8. Using Update to update an Access field

9. Populating a contact's Note field using automation with Access

10. Accessing custom fields in MS Project 2000

11. Using CreateObject to Access the currently loaded MS Project file

12. Access MS Project data via the Microsoft.Project.OLEDB.9.0 in ASP

 

 
Powered by phpBB® Forum Software