Using MS Access to populate specific fields in MS Project 
Author Message
 Using MS Access to populate specific fields in MS Project

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 lines
of code, i.e., "objProject.SetTaskField "Name", dynTasks!Tasks,
intCurrTask", I get the following error message when I click on the command

     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

When I select the "Debug" option, my code appears with the first "objProject
SetTask Field . . ." that it comes across that creates the bug.

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
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



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

Exit Function


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

Exit Function

End Function

Mon, 27 Aug 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Using MS Access to populate fields in Project - UPDATE

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

3. Populating MS Access field description

4. Driving MS Project from MS Access 2000 developed application

5. Command button won't make use of module driving MS Project from MS Access 2000

6. Driving MS Project with MS Access

7. Saving data in MS Project 98 to MS Access

8. How can I import report from MS Access to MS Project

9. Regarding Accessing External database using MS-Access and MS-Visual Basic

10. MS Project 98 vs Ms Project 2000

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

12. Conversion from MS project 95 to MS project 2000


Powered by phpBB® Forum Software