If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > displaying results on row 12 column A

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-04, 17:53
inho78 inho78 is offline
Registered User
 
Join Date: Sep 2004
Posts: 113
displaying results on row 12 column A

hey guys,

im am currently pulling a database query and populating it in excel. It needs to start at row 12 column A and goes all the way across till the last field.

if you scroll to the bottom i modfied this part of the code

startRow = 12
startCol = A
endRow = 12
endCol = A

PROBLEM: When dataset populates the spreadsheet, it doesn't include accountnumber from this sql

It only starts at accountstatus__c . What values do i place in startrow,startcol,end rowm end col to get the fields everytime in same order? I can do this manually by selecting row 12. .

code:

Thank you

select AccountNumber, AccountStatus__c, Annual_Revenue__c, BillingCity, BillingCountry, BillingPostalCode, BillingState, BillingStreet, CreatedById, CreatedDate, CurrentPrimaryChallenge__c, Description, DLC_territory__c, External_Auditor__c, Fax, Id, Industry, Industry_2__c, Industry_3__c, LastModifiedById, LastModifiedDate, Name, OwnerId, Ownership, ParentId, Phone, Physical_City__c, Physical_Country__c, Physical_State__c, Physical_Street__c, Physical_Zip_Postal_Code__c, SystemModstamp, TickerSymbol, Type, Website from account

Private Sub DisplayQueryResultSet(ByVal qrs As QueryResultSet, ByVal PromptForDestination As Boolean, ByRef fieldNames() As String)

Dim r As Range
Dim startRow As Integer
Dim startCol As Integer
Dim endRow As Integer
Dim endCol As Integer
Dim i As Integer
Dim sobj As sobject
Dim fld As Field
Dim soql As String

On Error Resume Next
If PromptForDestination Then
' Set r = Application.InputBox(Prompt:="Select the destination cell for your data.", Type:=8)
'Else
Set r = Application.ActiveCell
End If

If Err.Number <> 0 Then
Debug.Print Err.Number & ": " & Err.Description
Exit Sub
End If

If r.Row < 12 Then
MsgBox "Please select a cell below row 11.", vbOKOnly + vbCritical, "Bad Destination Selection"
Exit Sub
End If

startRow = 12
startCol = A
endRow = 12
endCol = A

soql = Range("soql").Value

r.Worksheet.Names("query").RefersToRange.ClearCont ents
FormatData r.Worksheet.Names("query").RefersToRange

fieldNames = GetSOQLFieldList(soql)

endCol = startCol + UBound(fieldNames)

For i = LBound(fieldNames) To UBound(fieldNames)
r.Worksheet.Cells(endRow, startCol + i) = fieldNames(i)
Next

endRow = endRow + 1

For Each sobj In qrs
For i = LBound(fieldNames) To UBound(fieldNames)
Set fld = sobj.Item(fieldNames(i))
r.Worksheet.Cells(endRow, startCol + i) = fld.Value
Next
endRow = endRow + 1
Next
endRow = endRow - 1

AddDataRange r.Worksheet, startRow, endRow, startCol, endCol

FormatHeader r.Worksheet.Range(r.Worksheet.Cells(startRow, startCol), r.Worksheet.Cells(startRow, endCol))
r.Worksheet.Cells(startRow + 1, startCol).Select

End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On