[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

04/09/2008 at 01:50PM PDT, ID: 23309716
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.0

why I got the run time error when trying to execute the query from Access VBA

Asked by gfranco in Access Coding/Macros, Access Forms, Microsoft Excel Spreadsheet Software

Tags: Runt-time error 2147217900

I am trying to execute this query by VBA form, but i got the run time error.
I just ran the query isolated and i was working fine.
Also, i just left the parameters of the query by default and when i was executed with those parameters, my vba code ran fine too.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
This is the query
SELECT QuotesFile.Theater, QuotesFile.Country, QuotesFile.[Created By User Type], ([Customer Name]) AS Customer, IIf([Created By User Name] Is Null,"EMPTY",UCase([Created By User Name])) & " - " & [Created By User Type] AS [Created by], IIf([Converted By User Name] Is Null,"EMPTY",UCase([Converted By User Name])) & " - " & [Converted By User Type] AS [Converted by], Sum(IIf(QuotesFile.[Created By Source]='CSCC' And QuotesFile.[Create Convert]=0,1,0)) AS [CSCC-Q], Sum(IIf([Created By Source]="CSCC" And QuotesFile.[Create Convert]=0,QuotesFile.[Net Price],0)) AS [CSCC-Q-V], Sum(IIf(QuotesFile.[Created By Source]='IQT' And QuotesFile.[Create Convert]=0,1,0)) AS [IQT-Q], Sum(IIf([Created By Source]="IQT" And QuotesFile.[Create Convert]=0,QuotesFile.[Net Price],0)) AS [IQT-Q-V], Sum(IIf(QuotesFile.[Created By Source]='SCC' And QuotesFile.[Create Convert]=0,1,0)) AS [SCC-Q], Sum(IIf([Created By Source]="SCC" And QuotesFile.[Create Convert]=0,QuotesFile.[Net Price],0)) AS [SCC-Q-V], Sum(IIf([Created By Source]="CSCC",1,0))/Count([ID]) AS [QAR  %], Sum(IIf(QuotesFile.[Created By Source]='CSCC' And QuotesFile.[Create Convert]=1,1,0)) AS [CSCC-O], Sum(IIf([Created By Source]="CSCC" And QuotesFile.[Create Convert]=1,QuotesFile.[Net Price],0)) AS [CSCC-O-V], Sum(IIf(QuotesFile.[Created By Source]='IQT' And QuotesFile.[Create Convert]=1,1,0)) AS [IQT-O], Sum(IIf([Created By Source]="IQT" And QuotesFile.[Create Convert]=1,QuotesFile.[Net Price],0)) AS [IQT-O-V], Sum(IIf(QuotesFile.[Created By Source]='SCC' And QuotesFile.[Create Convert]=1,1,0)) AS [SCC-O], Sum(IIf([Created By Source]="SCC" And QuotesFile.[Create Convert]=1,QuotesFile.[Net Price],0)) AS [SCC-O-V], Sum(IIf([Converted By Source]="CSCC",1,0))/Count(IIf([Converted By Source],1,0)) AS [OAR  %], QuotesFile.[Creation Date]
FROM QuotesFile
WHERE (((QuotesFile.[Creation Date]) Between [Forms]![frmDataAnalysis]![txtFOM] And [Forms]![frmDataAnalysis]![txtEOM]))
GROUP BY QuotesFile.Theater, QuotesFile.Country, QuotesFile.[Created By User Type], ([Customer Name]), IIf([Created By User Name] Is Null,"EMPTY",UCase([Created By User Name])) & " - " & [Created By User Type], IIf([Converted By User Name] Is Null,"EMPTY",UCase([Converted By User Name])) & " - " & [Converted By User Type], QuotesFile.[Creation Date], LCase([Created By User]) & " - " & [Created By User Type]
HAVING (((QuotesFile.Theater)=[Forms]![frmDataAnalysis]![cboTheater]) AND ((QuotesFile.Country)=[Forms]![frmDataAnalysis]![cboCountry]));
 
VBA Code
Public Sub PivotTableExportData()
 
    Dim xlapp As Excel.Application
    Dim xlwb As Excel.Workbook
    Dim xlws As Excel.Worksheet
    Dim adors As ADODB.Recordset
    Dim x As Long
 
    Set xlapp = New Excel.Application
    xlapp.Visible = True
    Set xlwb = xlapp.Workbooks.Add
    Set xlws = xlwb.Worksheets(1)
    xlws.Name = "RawData"
 
    Set adors = New ADODB.Recordset
    adors.Open "qryPivotbyPartner", CurrentProject.Connection, adOpenStatic, adLockReadOnly
 
    For x = 1 To adors.Fields.Count
        xlws.Cells(1, x) = adors.Fields(x - 1).Name
    Next
    xlws.Cells(2, 1).CopyFromRecordset adors
 
    adors.Close
    Set adors = Nothing
    
      
    xlwb.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=xlws.Name & "!" & _
        xlws.Cells(1, 1).CurrentRegion.Address).CreatePivotTable TableDestination:="", _
        tableName:="PivotTable2", DefaultVersion:=xlPivotTableVersion10
    xlapp.ActiveSheet.PivotTableWizard TableDestination:=xlapp.ActiveSheet.Cells(3, 1)
    xlapp.ActiveSheet.Cells(3, 1).Select
    With xlapp.ActiveSheet.PivotTables("PivotTable2")
        '.AddFields RowFields:=Array("Customer Name", "Created by", "Converted by"), PageFields:="Created By User Type"
        .AddFields RowFields:=Array("Customer", "Data"), PageFields:="Created By User Type"
        '.AddFields RowFields:=Array("Created by", "Data")
        '.AddFields RowFields:=Array("Converted by", "Data")
        '.AddFields PageFields:=Array("Created By User Type", "Creation Date")
        '.AddFields RowFields:=Array(, "Data"), PageFields:="Country", PageFields:="Created By User Type"
        '.Selection.ShowDetail = False
        '.AddFields RowFields:=Array("Created by", "Data"), PageFields:="Country", PageFields:="Created By User Type"
        '.AddFields RowFields:=Array("Customer", "Data"), PageFields:="Country"
        '.Name = "Verdana"
        '.Size = 8
        
        With .PivotFields("CSCC-Q")
            .Orientation = xlDataField
            .Caption = "Number CSCC-Q"
            .Position = 1
            .Function = xlCount
        End With
        With .PivotFields("CSCC-Q-V")
            .Orientation = xlDataField
            .Caption = "Total CSCC-Q-V"
            .Position = 2
            .Function = xlSum
            .NumberFormat = "$#,##0.00"
        End With
        With .PivotFields("IQT-Q")
            .Orientation = xlDataField
            .Caption = "Number IQT-Q"
            .Position = 3
            .Function = xlCount
        End With
        With .PivotFields("IQT-Q-V")
            .Orientation = xlDataField
            .Caption = "Total IQT-Q"
            .Position = 4
            .Function = xlSum
            .NumberFormat = "$#,##0.00"
        End With
        With .PivotFields("SCC-Q")
            .Orientation = xlDataField
            .Caption = "Number SCC-Q"
            .Position = 5
            .Function = xlCount
        End With
        With .PivotFields("SCC-Q-V")
            .Orientation = xlDataField
            .Caption = "Total SCC-Q-V"
            .Position = 6
            .NumberFormat = "$#,##0.00"
        End With
        With .PivotFields("CSCC-O")
            .Orientation = xlDataField
            .Caption = "Number CSCC-O"
            .Position = 7
            .Function = xlCount
        End With
        With .PivotFields("CSCC-O-V")
            .Orientation = xlDataField
            .Caption = "Total CSCC-O-V"
            .Position = 8
            .NumberFormat = "$#,##0.00"
        End With
        With .PivotFields("IQT-O")
            .Orientation = xlDataField
            .Caption = "Number IQT-O"
            .Position = 9
            .Function = xlCount
        End With
        With .PivotFields("IQT-O-V")
            .Orientation = xlDataField
            .Caption = "Total IQT-O"
            .Position = 10
            .NumberFormat = "$#,##0.00"
        End With
        With .PivotFields("SCC-O")
            .Orientation = xlDataField
            .Caption = "Number SCC-O"
            .Position = 11
            .Function = xlCount
        End With
        With .PivotFields("SCC-O-V")
            .Orientation = xlDataField
            .Caption = "Total SCC-O-V"
            .Position = 12
            .NumberFormat = "$#,##0.00"
        End With
        'With .PivotFields("OAR %")
        '   .Orientation = xlDataField
        '    .Caption = "% Orders-Adoption"
        '    .Position = 13
            '.NumberFormat = "$#,##0.00"
        'End With
        With .DataPivotField
            .Orientation = xlColumnField
            .Position = 1
        End With
    End With
    
    xlapp.ActiveSheet.Name = "Pivot-Data"
 
    Set xlws = Nothing
    Set xlwb = Nothing
    Set xlapp = Nothing
 
    MsgBox "Done"
 
End Sub
Attachments:
 
 
 
run time error
run time error
 
[+][-]04/09/08 02:22 PM, ID: 21319199

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/09/08 03:10 PM, ID: 21319567

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/09/08 03:14 PM, ID: 21319598

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/09/08 07:03 PM, ID: 21321093

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/10/08 02:06 AM, ID: 21322889

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/10/08 09:11 AM, ID: 21326369

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/10/08 09:27 AM, ID: 21326579

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/10/08 09:35 AM, ID: 21326671

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/10/08 09:50 AM, ID: 21326848

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 07:59 AM, ID: 21334866

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 08:07 AM, ID: 21334950

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/11/08 08:17 AM, ID: 21335067

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 08:40 AM, ID: 21335289

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/11/08 10:28 AM, ID: 21336292

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 10:35 AM, ID: 21336356

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/11/08 11:04 AM, ID: 21336640

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 11:33 AM, ID: 21336898

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/11/08 03:08 PM, ID: 21338602

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/11/08 04:26 PM, ID: 21338945

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 06:07 PM, ID: 21339392

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Access Forms, Microsoft Excel Spreadsheet Software
Tags: Runt-time error 2147217900
Sign Up Now!
Solution Provided By: harfang
Participating Experts: 2
Solution Grade: B
 
 
[+][-]04/11/08 06:11 PM, ID: 21339403

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/11/08 06:16 PM, ID: 21339408

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/15/08 10:47 AM, ID: 21360910

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/15/08 11:17 AM, ID: 21361225

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/15/08 11:55 AM, ID: 21361606

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/15/08 12:08 PM, ID: 21361737

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/15/08 12:21 PM, ID: 21361884

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/15/08 01:49 PM, ID: 21362734

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/17/08 07:40 AM, ID: 21377571

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/11/08 12:10 PM, ID: 21763190

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/11/08 01:14 PM, ID: 21763760

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06/11/08 01:27 PM, ID: 21763875

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_2_20070628