| | |
VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
![]() |
•
•
Join Date: Jul 2007
Posts: 113
Reputation:
Solved Threads: 0
VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#1 Jul 14th, 2007
Hi everyone,
if you can recall from my previous posting, I had explained that my "spreadshit does not fit into the same page", but I've now unraveled what the other programmer did to accomplish this goal:
looking at the input table to my spreadsheet, he first used "queryDef" to generate a query, then transfered the query output into a recordset (Access file). Because the recordsets are too long to fit into a spreadsheet, causing the spreadsheet to break up into two parts during printing, he used the "char(10) to break up the recordsets forming two lines of data within the same recordset. For example:
Query Table items:
----------------------
firstname Lastname amount oldhours newhours olddate newdate
====== ====== ===== ====== ===== ===== ======
Michael Jackson 100.00 15.00000 20.00000 02/2/07 02/03/07
Recordset output using char(10) to split the recordset into two line:
----------------------------------------------------------------------------
firstname Lastname amount hours date
====== ====== ===== === ======
Michael Jackson 100.00 15.00 02/02/07
--------- -------------- -------- 20.00 02/03/07
As you can see from the above record , the previous one line of reecord is now two lines, but within the same recordset, making it possible to fit the long record into the spreadsheet.
Now, I was using "CopyFromRecordset" function to import my access file into the spreadsheet, but the carriage return does not take effect to split the record into two lines within the same row.
My objective is to programatically populate the spreadsheet making it possible to fit two lines within the same recordset(row) as in the above example.
Thanks for your anticipated input.
tgifgemini
if you can recall from my previous posting, I had explained that my "spreadshit does not fit into the same page", but I've now unraveled what the other programmer did to accomplish this goal:
looking at the input table to my spreadsheet, he first used "queryDef" to generate a query, then transfered the query output into a recordset (Access file). Because the recordsets are too long to fit into a spreadsheet, causing the spreadsheet to break up into two parts during printing, he used the "char(10) to break up the recordsets forming two lines of data within the same recordset. For example:
Query Table items:
----------------------
firstname Lastname amount oldhours newhours olddate newdate
====== ====== ===== ====== ===== ===== ======
Michael Jackson 100.00 15.00000 20.00000 02/2/07 02/03/07
Recordset output using char(10) to split the recordset into two line:
----------------------------------------------------------------------------
firstname Lastname amount hours date
====== ====== ===== === ======
Michael Jackson 100.00 15.00 02/02/07
--------- -------------- -------- 20.00 02/03/07
As you can see from the above record , the previous one line of reecord is now two lines, but within the same recordset, making it possible to fit the long record into the spreadsheet.
Now, I was using "CopyFromRecordset" function to import my access file into the spreadsheet, but the carriage return does not take effect to split the record into two lines within the same row.
My objective is to programatically populate the spreadsheet making it possible to fit two lines within the same recordset(row) as in the above example.
Thanks for your anticipated input.
tgifgemini
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#2 Jul 14th, 2007
Hi,
Open the RecordSet from the query and Populate Access.
Check this Code:
RST>Recordset Open
Regards
Veena
Open the RecordSet from the query and Populate Access.
Check this Code:
RST>Recordset Open
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim i As Long i=0 Do While Not RST.EOF i=i+1 ExelWS.Cells(i, 1).Value = RST(0) ExelWS.Cells(i, 2).Value = RST(1) ExelWS.Cells(i, 3).Value = RST(2) ExelWS.Cells(i, 4).Value = RST(3) ExelWS.Cells(i, 5).Value = RST(4) i=i+1 ExelWS.Cells(i, 4).Value = RST(5) ExelWS.Cells(i, 5).Value = RST(6) ' RST.MoveNext Loop
Regards
Veena
Last edited by QVeen72; Jul 14th, 2007 at 6:02 am.
•
•
Join Date: Jul 2007
Posts: 113
Reputation:
Solved Threads: 0
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#3 Jul 15th, 2007
•
•
Join Date: Jul 2007
Posts: 113
Reputation:
Solved Threads: 0
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#4 Jul 17th, 2007
Hello Veena,
you gave me these codes to populate a spreadsheet one at a time from a recordset. What happens when you don't know how many cells/rows you need to populate in the spreadsheet? How would you code populating number of cells/rows based on the number of data in the recordset?
Below is the initial code you supplied:
Open the RecordSet from the query and Populate Access.
Check this Code:
RST>Recordset Open
Dim i As Long
i=0
Do While Not RST.EOF
i=i+1
ExelWS.Cells(i, 1).Value = RST(0)
ExelWS.Cells(i, 2).Value = RST(1)
ExelWS.Cells(i, 3).Value = RST(2)
ExelWS.Cells(i, 4).Value = RST(3)
ExelWS.Cells(i, 5).Value = RST(4)
i=i+1
ExelWS.Cells(i, 4).Value = RST(5)
ExelWS.Cells(i, 5).Value = RST(6)
'
RST.MoveNext
Loop
Regards
Veena
you gave me these codes to populate a spreadsheet one at a time from a recordset. What happens when you don't know how many cells/rows you need to populate in the spreadsheet? How would you code populating number of cells/rows based on the number of data in the recordset?
Below is the initial code you supplied:
Open the RecordSet from the query and Populate Access.
Check this Code:
RST>Recordset Open
Dim i As Long
i=0
Do While Not RST.EOF
i=i+1
ExelWS.Cells(i, 1).Value = RST(0)
ExelWS.Cells(i, 2).Value = RST(1)
ExelWS.Cells(i, 3).Value = RST(2)
ExelWS.Cells(i, 4).Value = RST(3)
ExelWS.Cells(i, 5).Value = RST(4)
i=i+1
ExelWS.Cells(i, 4).Value = RST(5)
ExelWS.Cells(i, 5).Value = RST(6)
'
RST.MoveNext
Loop
Regards
Veena
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#5 Jul 17th, 2007
•
•
Join Date: Jul 2007
Posts: 113
Reputation:
Solved Threads: 0
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#6 Jul 17th, 2007
Good morning Veena,
just a little calarification:
does these codes:
is the above code setting up the columns(recordset nodes -
Fname, Lname, age, salary, hours etc.... ?
in otherwords setting up each record?
I am just wondering why I'm hard-coding Thanks
tgifgemini.
just a little calarification:
does these codes:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
ExelWS.Cells(i, 1).Value = RST(0) ExelWS.Cells(i, 2).Value = RST(1) ETC......
is the above code setting up the columns(recordset nodes -
Fname, Lname, age, salary, hours etc.... ?
in otherwords setting up each record?
I am just wondering why I'm hard-coding
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
rs(0) to rs(6)
tgifgemini.
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#7 Jul 18th, 2007
try to make a variable for y axis by setting it to the number of records of your data to make your code more flexible...
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#8 Jul 18th, 2007
•
•
Join Date: Jul 2007
Posts: 113
Reputation:
Solved Threads: 0
Re: VB6/Excel - Using Char(10) to fit a long rcrdset as two lines within same recordset
0
#9 Jul 18th, 2007
![]() |
Similar Threads
- vb6-excel (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Problem
- Next Thread: Send Outlook email thru VB
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





