[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

populating mshflexgrid at runtime.

Posted on 2006-05-23
4
Medium Priority
?
329 Views
Last Modified: 2013-12-25
The query below does not populate the msflexgrid1. Can someone pleaes tell me what is wrong?

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database.mdb;Persist Security Info=False"
esql = "select Firstname, LastName, Address, PhoneNumber from Dataset2 where FirstName= """ & CmbFirst.Text & """ and LastName = """ & CmbLast.Text & """ And Address = """ & CmbAddress.Text & """ And PhoneNumber = """ & CmbPhone.Text & """;"
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
For row = 1 To rec.RecordCount - 1
For col = 1 To 4
Results.MSFlexGrid1.TextMatrix(row, col) = rec(col)
Next col
Next row
conn.Close
Set conn = Nothing

Thank you.
0
Comment
Question by:Aiysha
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 2000 total points
ID: 16746081
You need to teel msflexgrid the number of rows before you populate it:

.....
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
MSFlexGrid1.Rows = rec.RecordCount  '< number of rows
For row = 1 To MSFlexGrid1.Rows - 1
For col = 1 To 4
Results.MSFlexGrid1.TextMatrix(rec.AbsolutePosition, col) = rec(col)  'here the row can be the AbsolutePosition of the record
Next col
Next row
conn.Close
.....

S
0
 

Author Comment

by:Aiysha
ID: 16746915
Shauli,

I have the following code and it still doesnt work.

rec.Open (esql), conn, adOpenStatic, adLockReadOnly
Results.MSFlexGrid1.Rows = rec.RecordCount + 1
For row = 2 To rec.RecordCount + 1
For col = 2 To 5
Results.MSFlexGrid1.TextMatrix(row, col).Text = rec(col)  <-----error
Next col
Next row
conn.Close
Set conn = Nothing
0
 
LVL 2

Expert Comment

by:samstarkey
ID: 16747062
0
 
LVL 19

Expert Comment

by:Shauli
ID: 16747295
Whu di you add the .Text to the line?

Results.MSFlexGrid1.TextMatrix(row, col).Text = rec(col)  <-----error
'                                                          ^^^^

It should be:

Results.MSFlexGrid1.TextMatrix(row, col)= rec(col)  <-----no more error

S
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question