Driving MS Project from MS Access 2000 developed application 
Author Message
 Driving MS Project from MS Access 2000 developed application

I have developed a strategic planning software application using MS ACCESS
2000.  I can generate all the tasks activity reports I want.  But, it would
be great if I could generate MS Project timelines driven FROM my MS Access
application.  However, I'm using code via a command button (see, below) that
I am told will not work in MS Access 2000, and that I should be using Active
X.  Any ideas?

I used a book called, "Access 97 Power Programming, by Scott Bullock Access
Development manager Microsoft".  On page 362-365 it presents the following
code on how it works:

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

SetobjProject = CreateObject(Class:="MSProject.Application.4_1")

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

Thanks,

John Phelan

Thanks,
John Phelan



Tue, 14 Aug 2001 03:00:00 GMT  
 Driving MS Project from MS Access 2000 developed application
Perhaps the advice you were given had to do with the fact that you are
using a DAO recordset rather than an ADO recordset. Maybe the A in ADO
is the "ActiveX" you referred to. Your code will work as long as you
open the References dialog and set a reference to DAO (if one isn't
set already). You then just need to change the recordset declaration
to:
Dim dynTasks As DAO.Recordset

Alternatively, you could change your syntax to work with an ADO
recordset, but if you are using other existing code, sticking with DAO
will be easier while you start learning about ADO.

 -- Andy

Quote:

>I have developed a strategic planning software application using MS ACCESS
>2000.  I can generate all the tasks activity reports I want.  But, it would
>be great if I could generate MS Project timelines driven FROM my MS Access
>application.  However, I'm using code via a command button (see, below) that
>I am told will not work in MS Access 2000, and that I should be using Active
>X.  Any ideas?

>I used a book called, "Access 97 Power Programming, by Scott Bullock Access
>Development manager Microsoft".  On page 362-365 it presents the following
>code on how it works:

>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

>SetobjProject = CreateObject(Class:="MSProject.Application.4_1")

>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

>Thanks,

>John Phelan

>Thanks,
>John Phelan



Thu, 16 Aug 2001 03:00:00 GMT  
 Driving MS Project from MS Access 2000 developed application
Andy,

Thanks for your advise.  I made the change as you suggest.  No more =
error
messages.  I created the command button with the following set for the =
on
click's Event Procedure, but nothing happens:

Private Sub Command38_Click()
End Sub
Function AccessToProjectAutomation()
End Function

I feel that I'm getting closer, but there's something still missing.

Thanks,
John


Quote:
>Perhaps the advice you were given had to do with the fact that you are
>using a DAO recordset rather than an ADO recordset. Maybe the A in ADO
>is the "ActiveX" you referred to. Your code will work as long as you
>open the References dialog and set a reference to DAO (if one isn't
>set already). You then just need to change the recordset declaration
>to:
>Dim dynTasks As DAO.Recordset

>Alternatively, you could change your syntax to work with an ADO
>recordset, but if you are using other existing code, sticking with DAO
>will be easier while you start learning about ADO.

> -- Andy


>>I have developed a strategic planning software application using MS ACCESS
>>2000.  I can generate all the tasks activity reports I want.  But, it
would
>>be great if I could generate MS Project timelines driven FROM my MS Access
>>application.  However, I'm using code via a command button (see, below)
that
>>I am told will not work in MS Access 2000, and that I should be using
Active
>>X.  Any ideas?

>>I used a book called, "Access 97 Power Programming, by Scott Bullock
Access
>>Development manager Microsoft".  On page 362-365 it presents the following
>>code on how it works:

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

>>SetobjProject = CreateObject(Class:="MSProject.Application.4_1")

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

>>Thanks,

>>John Phelan

>>Thanks,
>>John Phelan



Thu, 16 Aug 2001 03:00:00 GMT  
 Driving MS Project from MS Access 2000 developed application
If you want to call the function from your event procedure, then you
need to use syntax like this:

Private Sub Command38_Click()
  Call AccessToProjectAutomation()
End Sub

Or, without creating an event procedure, you can put this in the
OnClick event property of the command button, where it now reads
[Event Procedure]:
=AccessToProjectAutomation()

This assumes that the function called AccessToProjectAutomation()
exists in a module in your project.

And with only the most friendly of intentions, I suggest that you
learn a bit more about the basics of using VBA in an Access
application before trying to go too far copying and pasting code that
you find in a book. :-)

 -- Andy

Quote:

>Andy,

>Thanks for your advise.  I made the change as you suggest.  No more =
>error
>messages.  I created the command button with the following set for the =
>on
>click's Event Procedure, but nothing happens:

>Private Sub Command38_Click()
>End Sub
>Function AccessToProjectAutomation()
>End Function

>I feel that I'm getting closer, but there's something still missing.

>Thanks,
>John



>>Perhaps the advice you were given had to do with the fact that you are
>>using a DAO recordset rather than an ADO recordset. Maybe the A in ADO
>>is the "ActiveX" you referred to. Your code will work as long as you
>>open the References dialog and set a reference to DAO (if one isn't
>>set already). You then just need to change the recordset declaration
>>to:
>>Dim dynTasks As DAO.Recordset

>>Alternatively, you could change your syntax to work with an ADO
>>recordset, but if you are using other existing code, sticking with DAO
>>will be easier while you start learning about ADO.

>> -- Andy


>>>I have developed a strategic planning software application using MS ACCESS
>>>2000.  I can generate all the tasks activity reports I want.  But, it
>would
>>>be great if I could generate MS Project timelines driven FROM my MS Access
>>>application.  However, I'm using code via a command button (see, below)
>that
>>>I am told will not work in MS Access 2000, and that I should be using
>Active
>>>X.  Any ideas?

>>>I used a book called, "Access 97 Power Programming, by Scott Bullock
>Access
>>>Development manager Microsoft".  On page 362-365 it presents the following
>>>code on how it works:

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

>>>SetobjProject = CreateObject(Class:="MSProject.Application.4_1")

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

>>>Thanks,

>>>John Phelan

>>>Thanks,
>>>John Phelan



Fri, 17 Aug 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

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

2. MS Project 98 vs Ms Project 2000

3. Conversion from MS project 95 to MS project 2000

4. Driving MS Project with MS Access

5. Executing MS SQL Server 2000 stored procs via MS Access 2000

6. progress bar error by modification (MS Project 2000, MS SQL 7.0 and IIS 5)

7. Accessing custom fields in MS Project 2000

8. Save as access database in MS Project 2000

9. Find Tasks created from MS Project 2000 in Outlook 2000

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

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

12. Saving data in MS Project 98 to MS Access

 

 
Powered by phpBB® Forum Software