Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO and GetRows and some advice

Status
Not open for further replies.

rb74

Programmer
May 5, 2002
64
US
I posted this in the VB5 & VB6 forum, but I had no idea this forum existed. Cool.

I hope you all are having a good weekend.

I have a recordset with x amount of records that will have 30 fields each. I would like to have the records input into a 2D array. I am using the GetRows method, but VB is inputting the records in reverse order so to speak. Instead of having the array populated (i.e. rows, columns) like a normal database record, my array is populated (columns, rows) in reverse, so to speak. How can I get it populated in the right fashion?

I also would like some advice about the method I am using. My app allows the user to search for records in the database by a member last name. The data in the recordset then populates a FlexGrid to allow the user to choose a record to view on the input form. My design calls for the data in the recordset to populate an array then for the app to take the data in the array and populate the objects on the input form. Would it be easier for me to use the recordset to populate the objects on the input form and bypass using an array? If so, I tried to make my recordset public, but the search function would not work (the sub procedure that contains the recordset is public).

Any suggestions?

Thanks,

Rob [Vader2]
 
It would be easier to use the flexgrid to house all the data and populate the input form controls on the flexgrid's onclick event. You can display the recordset fields the user needs to make the selection and hide the rest by setting the fg.ColWidth(col) to 0. It sounds as though the input form objects are not bound, and you'll have to update the recordset and/or the source table once the user makes the changes. But you do bypass the array.

Also check out the ADO GetString() for loading the flexgrid.

' set the number of rows to accomodate the record count
fg.rows = rs.RecordCount - 1
'set the number of columns as well
fg.cols = rs.Fields.Count - 1
' set a selection block the same size as the recordset
fg.row = 0
fg.col = 0
fg.rowsel = fg.rows - 1
fg.colsel = fg.cols - 1
' "Paste" the recordset in the flexgrid
fg.clip = rs.GetString(adClipString, -1, vbTab, vbCrLf)


Mark
 
Hi Mark,

Thanks for the advice. I should have posted some more information. The flexgrid is not my problem, it was the array. But your suggestion to use the flexgrid instead of the array is a good, but for the purposes of the search, the user only needs to view about 10 of the 30 fields for a record in the recordset. I have a main input form which has an SSTab with 3 tabs. The first tab is for the data entry, the second is to view the data entered in a report format, and the third tab is for the flexgrid. I have two Sub Procedures so far for this task: one is to search for records in the db based upon the user entering a client's last name. This procedure then posts the data in the flexgrid. The next procedure is the click event on the flexgrid where it is set to trap the record requested by the user. By using the flexgrid only, I can bypass the array and some headaches. I will try and give it a shot

Thanks again,

Rob [Vader2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top