G
Guest
I have to fix the procedure to export data to MS Project. In the code below:
===============================
Option Compare Database
Option Explicit
Sub ReportToProject(Optional lngGroupID As Long, Optional lngSubGroupID As
Long)
Dim cnn As Object
Dim rsExport As Object, rsExportRes As Object
Dim pj As Object, apj As Object
Dim intCounter As Integer, lngTotalRecords As Long
Dim strProjectName As String, strPath As String
Dim strCurrentAsset As String, intCreateproject As Integer
Dim strGroupName As String
Dim blnExists As Boolean
MsgBox "started the function"
MsgBox "GroupID = " & lngGroupID
MsgBox "SubGroupID = " & lngSubGroupID
On Error GoTo Err_ReportToProject
'set variables
Set cnn = CurrentProject.Connection
Set rsExport = CreateObject("ADODB.Recordset")
Set rsExportRes = CreateObject("ADODB.Recordset")
If lngGroupID = 0 Then
rsExport.Open "SELECT * FROM qryExportToProject1", cnn, 1
rsExportRes.Open "SELECT * FROM qryExportResources", cnn, 1
Else
If lngSubGroupID = 0 Then
rsExport.Open "SELECT * FROM qryExportToProject1 WHERE
lngGeneralGroupsID = " & lngGroupID, cnn, 1
rsExportRes.Open "SELECT * FROM qryExportResources WHERE
[tblGeneralGroups].[lngGeneralGroupsID] = " & lngGroupID, cnn, 1
Else
rsExport.Open "SELECT * FROM qryExportToProject1 WHERE
lngAssetGroupID = " & lngSubGroupID, cnn, 1
rsExportRes.Open "SELECT * FROM qryExportResources WHERE
lngAssetGroupID = " & lngSubGroupID, cnn, 1
End If
End If
.......
==========================
I am getting an eror:
-2147217904 when the process is reaching the If area.
Queries - qryExportToProject and qryExportResources are working fine.
Parameters are passed to the module itself. What parameters are missing in my
IF statements ?
Thanks for help.
Regards,
Tony
===============================
Option Compare Database
Option Explicit
Sub ReportToProject(Optional lngGroupID As Long, Optional lngSubGroupID As
Long)
Dim cnn As Object
Dim rsExport As Object, rsExportRes As Object
Dim pj As Object, apj As Object
Dim intCounter As Integer, lngTotalRecords As Long
Dim strProjectName As String, strPath As String
Dim strCurrentAsset As String, intCreateproject As Integer
Dim strGroupName As String
Dim blnExists As Boolean
MsgBox "started the function"
MsgBox "GroupID = " & lngGroupID
MsgBox "SubGroupID = " & lngSubGroupID
On Error GoTo Err_ReportToProject
'set variables
Set cnn = CurrentProject.Connection
Set rsExport = CreateObject("ADODB.Recordset")
Set rsExportRes = CreateObject("ADODB.Recordset")
If lngGroupID = 0 Then
rsExport.Open "SELECT * FROM qryExportToProject1", cnn, 1
rsExportRes.Open "SELECT * FROM qryExportResources", cnn, 1
Else
If lngSubGroupID = 0 Then
rsExport.Open "SELECT * FROM qryExportToProject1 WHERE
lngGeneralGroupsID = " & lngGroupID, cnn, 1
rsExportRes.Open "SELECT * FROM qryExportResources WHERE
[tblGeneralGroups].[lngGeneralGroupsID] = " & lngGroupID, cnn, 1
Else
rsExport.Open "SELECT * FROM qryExportToProject1 WHERE
lngAssetGroupID = " & lngSubGroupID, cnn, 1
rsExportRes.Open "SELECT * FROM qryExportResources WHERE
lngAssetGroupID = " & lngSubGroupID, cnn, 1
End If
End If
.......
==========================
I am getting an eror:
-2147217904 when the process is reaching the If area.
Queries - qryExportToProject and qryExportResources are working fine.
Parameters are passed to the module itself. What parameters are missing in my
IF statements ?
Thanks for help.
Regards,
Tony