Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error with oRange
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01516312
Message ID:
01516481
Views:
37
Yep, lcOldCarr_Name was given a value of "" before the SCAN. I didn't put that into this posting initially. Sorry about that. I am still trying to get a hold on to automation. I have a particular approach that slams 12 months of data to the Excel file, one month at a time for 8 or 9 columns, skips a column and does it again from left to right. The problem I am having is how to lay out, let's say, the first month's data and show the groupings of Carriers. Let's say that Carrier 1 is called "ABC" and the second one is "ACE". I need to lay it out kind of like I would in a FoxPro report where you see the Column Headings with a Grouping of data under it, basically a Carrier Name and its details under it, then when the Group changes, you skip a row (making it a blank row), show the next Carrier and then all of its detail records under it. Then once the first month is completed, you jump 9 columns to the right and start the 2nd month's data, then jump 9 columns to the right for the 3rd month and so on. You might call this a tabular report in a way.
Cecil

>Maybe I'm missing it but I don't see where lcOldCarr_Name is defined before the SCAN.

>Assuming that you simply left it out of your cut and paste is it possible you defined it as ""? It that's the case your first IF condition will fail.
lcCarr_Name = "Carrier"
lcOldCarr_Name = ""
? lcCarr_Name <> lcOldCarr_Name ----> .F.
FOR nMonth = 1 TO lnMonths	&& 12
	WITH oExcel.ActiveSheet
		* Select the correct Month's cursor (table).
		lcMonth=PADL(nMonth, 2, "0")
		lcCursor=("tmpNearly"+lcMonth)
		SELECT (lcCursor)
		SCAN
			lcCarr_Name = &lcCursor..Carr_Name
			IF lcCarr_Name <> lcOldCarr_Name	&& Either frist time in, or you have a new carrier.
				* Move down a row for the new Carrier Name. Makes two rows.
				oRange = oRange.Offset(1,0)
				oExcel.ActiveSheet.Cells(lnRow-1,lnCol).Value = "Monthly-" + lcCarrierName
					* Put the name of the first report in A1.
				lcAlphaMonth = LEFT(GetAlphaMonth(nMonth),3)
				.Cells(lnRow-1,lnCol+3).Value = lcAlphaMonth + " " + lcYear
				* Lay out the Columnn Headers from Left to Right.
				.Cells(lnRow, lnCol).Value = "Group Name"
				.Cells(lnRow, lnCol + 1).Value = "GrpID"
				.Cells(lnRow, lnCol + 2).Value = "Emp. ID"
				.Cells(lnRow, lnCol + 3).Value = "Benefit"
				.Cells(lnRow, lnCol + 4).Value = "Month_Billed"
				.Cells(lnRow, lnCol + 5).Value = "Month_Collected"
				.Cells(lnRow, lnCol + 6).Value = "Annualized Premium"
				.Cells(lnRow, lnCol + 7).Value = "Lives"
			ENDIF
			*oxcel.ActiveSheet.Cells(lnRow-1,lnCol).Value = "Monthly-" + lcCarrierName
			WITH oRange
				* Print the columns/fields to the page. This runs left to right on the default row.
				.Columns[1].Value = GrpName			&& Group Name
				.Columns[2].Value = GrpID			&& Group ID
				.Columns[3].Value = Emp_ID			&& Employer's ID
				.Columns[4].Value = Benefit			&& Benefit Name.
				.Columns[5].Value = Billed			&& Monthly Billed Amount By GrpID, Employer.
				.Columns[6].Value = Collected		&& Monthly Collected amount by GrpID, Employer.
				.Columns[7].Value = Annualized		&& Annualized Premium.
				.Columns[8].Value = Lives			&& # of Primary Insured.
				* Move down one row.
				oRange = oRange.Offset(1,0)
			ENDWITH
			lcOldCarr_Name = &lcCursor..Carr_Name
		ENDSCAN
		* Since we've changed months, let's go to the right 9 columns.
		lnColsOffSetToRight=lnColsOffSetToRight + 9
		lnCol = lnColsOffSetToRight + 1
		oRange = .Range("A3:H3").Offset(0, lnColsOffSetToRight)
	ENDWITH
ENDFOR
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform